myController.java如何讓jboss顯示log.debug消息?
private static final Logger log = Logger.getLogger(myController.class
.getName());
@GET
@Path("/testDebug")
public String testDebug(@Context final ServletContext context)
{
log.error("This is an error message");
log.debug("This is a debug message");
log.fatal("This is fatal message");
log.warn("This is a warn message");
log.info("This is a info message");
return "Test Page. Debug Mode is on =" + log.isDebugEnabled();
}
的jboss-log4j.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!-- -->
<!-- Log4j Configuration -->
<!-- -->
<!-- ===================================================================== -->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/server.log"/>
<param name="Append" value="false"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
-->
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
<category name="org.apache">
<priority value="INFO"/>
</category>
<!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
<category name="org.jboss.serial">
<priority value="INFO"/>
</category>
<!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
<category name="org.jgroups">
<priority value="WARN"/>
</category>
<!-- Limit the jacorb category to WARN as its INFO is verbose -->
<category name="jacorb">
<priority value="WARN"/>
</category>
<!-- Limit JBoss categories -->
<category name="org.jboss">
<priority value="INFO"/>
<appender-ref ref="CONSOLE"/>
</category>
<!-- Limit the JSR77 categories -->
<category name="org.jboss.management">
<priority value="INFO"/>
</category>
<!-- This is is the package to myController.java -->
<category name="com.myPackage.src">
<priority value="DEBUG"/>
</category>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
所需的結果
時路徑/testDebug
被擊中得到的消息:「這是一個調試消息「
問題:
我得到的所有消息顯示除了調試
10:29:49,440 INFO [STDOUT] 10:29:49,440 ERROR [myController] This is an error message
10:29:49,440 INFO [STDOUT] 10:29:49,440 FATAL [myController] This is fatal message
10:29:49,440 INFO [STDOUT] 10:29:49,440 WARN [myController] This is a warn message
10:29:49,440 INFO [STDOUT] 10:29:49,440 INFO [myController] This is a info message
爲什麼不能我得到的調試消息顯示?
這pacakge是 –
@SurajChandran位置類是myController的com.myPackage.src.myController.java – stackoverflow