log4j debug messages not showing in console despite isDebugEnabled being true

前端 未结 2 1696
一生所求
一生所求 2021-02-07 15:18

I am using the following code within my project to log debug messages with log4j

private static final Logger LOG = Logger.getLogger(MyClass.class)
// ...
if(LOG.         


        
相关标签:
2条回答
  • 2021-02-07 15:50

    Make sure your configuration has below appender...We have used log4j.xml so i am adding from xml

    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Target" value="System.out" />
        <param name="Threshold" value="info" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-5p: %c - %m%n" />
        </layout>
    </appender>
    
    <appender name="logfile" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="log/dcm_migration.log" />
        <param name="Append" value="false" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d  %-5p  [%c{1}] %m %n" />
        </layout>
    </appender>
    
    0 讨论(0)
  • 2021-02-07 15:56
    log4j.appender.Stdout.threshold=info
    

    Should be:

    log4j.appender.Stdout.threshold=debug
    

    You just set the console threshold to be info, so you're not getting debug level logs.

    Be aware you also set the RollingFileAppender threshold to info as @Stephen C commented.

    0 讨论(0)
提交回复
热议问题