I am using log4j xml configuration for my project, NOT log4j.properties file. I am trying to display debug messages in eclipse console. But it didn't worked out. Instead, info messages are being displayed.
Below is my log4j xml configuration file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="debug" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
</layout>
</appender>
<root>
<level value ="debug" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
In my code I am checking what log level is set this way
if(LOG.isDebugEnabled()){
LOG.debug("debug is enabled");
LOG.info("Debug enabled but using info to display this message");
System.out.println("sys out debug is enabled");
}
My eclipse console log output is hereunder:
12:08:51,191 INFO [com.abc.servlets.MainServlet] (http-localhost-127.0.0.1-8080-2) Debug enabled but using info to display this message
12:08:51,192 INFO [stdout] (http-localhost-127.0.0.1-8080-2) sys out debug is enabled
Additional Information : I am using Jboss App server.
Still working on this, it didn't strike for me where I was wrong.
Should it be
instead of
in