1

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.

1
  • Everything looks perfect however I want to suggest some silly idea. Put the root node before the appender and lets give it a try... Commented Sep 13, 2013 at 6:59

1 Answer 1

2

Should it be

<priority value ="debug" />

instead of

<level value ="debug" /> 

in

 <root> 
    <level value ="debug" /> 
    <appender-ref ref="console" /> 
  </root>
Sign up to request clarification or add additional context in comments.

1 Comment

Whenever you downvote, please leave a comment for me to learn for future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.