Why is log4j not behaving as expected?

Posted by Kieveli on Stack Overflow See other posts from Stack Overflow or by Kieveli
Published on 2010-03-19T15:25:10Z Indexed on 2010/03/19 15:41 UTC
Read the original article Hit count: 281

Filed under:
|

I have a co-worker who is trying to get log4j to behave as follows:

  • Log to Stdout
  • By default, disable most output
  • Show only messages from java.sql.PrepareStatement at level debug and up

He's getting caught up in the 'level' vs 'priority'. Here is his config file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "D:/Java/apache-log4j-1.2.15/src/main/resources/org/apache/log4j/xml/log4j.dtd" >
<log4j:configuration> 

    <!--  Appenders -->
    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%5p %d{ISO8601} [%t][%x] %c - %m%n" />
        </layout>
    </appender>

    <!--  Loggers for ibatus and JDBC database -->
    <logger name="java.sql.PreparedStatement">
        <level value="debug"/>
    </logger>

    <!--  The Root Logger -->
    <root>
        <level value="error"/>
        <appender-ref ref="stdout"/>
    </root>

</log4j:configuration>

The output from this shows no messages in the log output.

How does he need to change his log4j.xml config file to make it behave as he's expecting?

© Stack Overflow or respective owner

Related posts about log4j

Related posts about configuration