You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ke...@indus.com on 2002/11/13 19:11:05 UTC

commons-logging and log4j outputting log msgs twice

I'm having trouble configuring commons-logging and log4j. I've got it
working as I think I should, but for every log call I am getting 2 lines
output to the log, one using the formatting specified in my appender, and
the other with another format that I am not defining.

Heres my log4j.properties:
log4j.logger.org.apache=WARN

#define logger for kh package
log4j.logger.kh=DEBUG, Console, Rolling

log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.Console.layout.ConversionPattern=%d{ISO8601}   [%C{1}] -
%m%n

log4j.appender.Rolling=org.apache.log4j.RollingFileAppender
log4j.appender.Rolling.File=testlog.log
log4j.appender.Rolling.MaxFileSize=10KB
log4j.appender.Rolling.MaxBackupIndex=1
log4j.appender.Rolling.layout=org.apache.log4j.PatternLayout
log4j.appender.Rolling.layout.ConversionPattern=%d{ISO8601}   [%C{1}] -
%m%n

Heres my commons-logging.properties:
#kh 11/06/02
# commons logging config - use Log4J
org.apache.commons.logging.Log =
org.apache.commons.logging.impl.Log4JCategoryLog

Heres a test app:
package kh;

import org.apache.commons.logging.*;

public class CommonsLoggingExample
      {
      public static void main(String[] args)
            {
            Log log = LogFactory.getLog(CommonsLoggingExample.class);

            log.info("Test info message");
            log.warn("Test warn message");
            log.error("Test error message");
            log.debug("Test debug message");
            }
      }

And heres the output I get to the console:

2002-11-13 10:05:23,711   [CommonsLoggingExample] - Test info message
0 [main] INFO kh.CommonsLoggingExample  - Test info message
2002-11-13 10:05:23,791   [CommonsLoggingExample] - Test warn message
80 [main] WARN kh.CommonsLoggingExample  - Test warn message
2002-11-13 10:05:23,801   [CommonsLoggingExample] - Test error message
90 [main] ERROR kh.CommonsLoggingExample  - Test error message
2002-11-13 10:05:23,801   [CommonsLoggingExample] - Test debug message
90 [main] DEBUG kh.CommonsLoggingExample  - Test debug message

Any idea how I can suppress the log message that are prefixed with '90
[main] ' etc?

Thanks in advance,
Kevin Hooke

****************************************
This email message and all attachments transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and
privileged information. Please DO NOT forward this email outside of the recipient's Company unless expressly authorized to do so herein.  Any
unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email
and destroy all copies of the original message.

Any views expressed in this email message are those of the individual sender except where the sender specifically states them to be the views of Indus
 International, Inc.
****************************************



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>