How to enable Logger.debug() in Log4j

前端 未结 8 1839
谎友^
谎友^ 2020-12-07 18:53

While trying to execute the following lines only the last two statements are displayed(\"Here is some ERROR\" and \"Here is some FATAL\") and the first three statements are

8条回答
  •  囚心锁ツ
    2020-12-07 19:25

    This is probably happening because your log4j configuration is set to ERROR. Look for a log4j.properties file with contents like the following:

    log4j.rootLogger=ERROR, CONSOLE
    
    # console logging
    log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
    log4j.appender.CONSOLE.Threshold=DEBUG
    log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
    log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %-20.20t %-24c{1}: %m%n
    

    The rootLogger is set to ERROR level here using a CONSOLE appender.

    Note that some appenders like the console appender also have a Threshold property that can be used to overrule the rootLoggers level. You need to check both in this case.

提交回复
热议问题