I just did a test with 1.2.8 and got different results. Please retest.
In sps.wfds.biz.glacier.JDocOptions: logger.info("logger.isDebugEnabled()=" + logger.isDebugEnabled()); <!-- No loggers under sps.wfds defined so the following applies --> <logger name="sps"> <level value="debug"/> <appender-ref ref="OutputApp"/> </logger> INFO 27:56.449 sps.wfds.biz.glacier.JDocOptions logger.isDebugEnabled()=false On 3/16/07, James Stauffer <[EMAIL PROTECTED]> wrote:
The results you claim are surprising. I don't expect it to check for the existence of a logger but I do expect the fact that the effective level is info would cause isDebugEnabled() to return false. On 3/15/07, John Eisenman <[EMAIL PROTECTED]> wrote: > I'm using version 1.2.14 > > My expectation in using log4j was that a call to logger.isXXXEnabled() > would return true only in the case that a call to logger.XXX("some > message") would result in the message being written to some appender. > However, it appears that the existence of an appender has no bearing the > Enabled call. > > For example, I have this simple configuration: > > <?xml version="1.0" encoding="UTF-8" ?> > <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> > > <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> > > <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"> > <param name="Threshold" value="debug"/> > <layout class="org.apache.log4j.PatternLayout"> > <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n"/> > </layout> > </appender> > > <root> > <level value ="info"/> > <appender-ref ref="STDOUT"/> > </root> > </log4j:configuration> > > > Using this configuration, and this program (based on log4j's examples): > > > package chapter3; > > import org.apache.log4j.Logger; > import org.apache.log4j.xml.DOMConfigurator; > > public class BugApp3 { > //final static Logger logger = Logger.getLogger(BugApp3.class); > final static Logger logger = Logger.getLogger("chapter3.BugApp3"); > > public static void main(String[] args) { > DOMConfigurator.configure(args[0]); > > logger.info("Entering application."); > > //debug is not enabled > logger.debug("Debug is enabled."); > > if (logger.isDebugEnabled()) { > logger.info("isDebugEnabled() returns true!"); > } > > logger.info("Exiting application."); > } > } > > I see the following output: > > % java chapter3.BugApp3 bug0.xml > 0 [main] INFO chapter3.BugApp3 - Entering application. > 2 [main] INFO chapter3.BugApp3 - isDebugEnabled() returns true! > 3 [main] INFO chapter3.BugApp3 - Exiting application. > > However, if I set the root level to "debug" instead, then I get this > output instead: > > % java chapter3.BugApp3 bug0.xml > 1 [main] INFO chapter3.BugApp3 - Entering application. > 3 [main] INFO chapter3.BugApp3 - Exiting application. > > Since the goal of an isXXXEnabled() statement is to avoid doing > unnecessary work in the case where it will not result in actual debug > output, it seems unfortunate that it does not take into account the > existence of an appender. > > Is this behavior intentional? > > -John > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- James Stauffer http://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/
-- James Stauffer http://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]