Because you have the appender attached to both the TestLog logger, and the root logger. By default, any log events going to a logger go to any appenders attached specifically to that logger, and then traverses up the logger hierarchy, looking for any appender attached to it up to and including the root logger.

This is known as logger additivity, and something that an be turned off at an individual logger, so during traversal if it hits a logger with additivity=false, it stops going up.

If you remove the appender attached to the TestLog logger, you'll get one line output, because the log gets output when it hits the root logger (and it's attached appender).

cheers,

Paul Smith
On 01/06/2006, at 3:19 PM, tony kerz wrote:

log4j 1.3alpha8

----------------------------------------
TestLog.java:
----------------------------------------

package com.kerz.test;

import org.apache.log4j.Logger;

public class TestLog
{
 private static Logger s_log = Logger.getLogger(TestLog.class);

 public static void main(String[] args)
 {
   s_log.debug("log4j!");
 }
}

----------------------------------------
log4j.xml:
----------------------------------------

<?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">
   <layout class="org.apache.log4j.PatternLayout">
     <param
       name="ConversionPattern"
       value="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
   </layout>
 </appender>
 <logger name="com.kerz.test.TestLog">
   <level value="debug" />
   <appender-ref ref="STDOUT" />
 </logger>

 <root>
   <level value="error" />
   <appender-ref ref="STDOUT" />
 </root>
</log4j:configuration>

----------------------------------------
console:
----------------------------------------

2006-06-01 01:04:36,937 DEBUG [main] test.TestLog (TestLog.java:23) - log4j! 2006-06-01 01:04:36,937 DEBUG [main] test.TestLog (TestLog.java:23) - log4j!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to