log4j - Why is logger.debug not working?

11,449
<param name="Threshold" value="INFO" />

Your threshold is set to INFO, that's one level below DEBUG, so any debug messages won't make it through the filter. See here for the relative levels:

Level       Description
=====       ===========
OFF         The highest possible rank and is intended to
            turn off logging.
FATAL       Severe errors that cause premature termination.
            Expect these to be immediately visible on a
            status console.
ERROR       Other runtime errors or unexpected conditions.
            Expect these to be immediately visible on a
            status console.
WARN        Use of deprecated APIs, poor use of API,
            'almost' errors, other runtime situations that
            are undesirable or unexpected, but not
            necessarily "wrong". Expect these to be
            immediately visible on a status console.
INFO        Interesting runtime events (startup or
            shutdown). Expect these to be immediately
            visible on a console, so be conservative
            and keep to a minimum.
DEBUG       Detailed information on the flow through
            the system. Expect these to be written to logs
            only.
TRACE       Most detailed information. Expect these to be
            written to logs only. Since version 1.2.12.
Share:
11,449
gran_profaci
Author by

gran_profaci

Programmer in the Bay.

Updated on June 04, 2022

Comments

  • gran_profaci
    gran_profaci almost 2 years

    My log4j.xml file has the following config:

       <appender name="fileAppender"
               class="org.apache.log4j.DailyRollingFileAppender">
          <param name="Threshold" value="INFO" />
          <!-- Change Log File Root when Environment is Set Up -->
          <param name="File" value="${root}/application.log"/>
        <param name="DatePattern" value=".yyyy-MM-dd" />
          <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%d{yyyy-MMM-dd HH:mm:ss,SSS} [%t] %c %x%n  %-5p %m%n"/>
          </layout>
       </appender>
    
       <logger name="db.scheduler" additivity="false" >
          <level value="all"/>
          <appender-ref ref="consoleAppender"/>
          <appender-ref ref="fileAppender"/>
       </logger>
    

    However. when I do logger.debug, it doesn't add anything! logger.info and logger.error work... but not logger.debug!

  • gran_profaci
    gran_profaci almost 11 years
    So I should change it to ALL ?
  • paxdiablo
    paxdiablo almost 11 years
    @gran_profaci, no. If you want debug messages, change it to debug. all will give you trace messages as well (which you may well want but your question asked specifically about logger.debug). If you want to see everything, and don't mind wading through a lot of data, by all means use tracing as well.