logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: odd Initialization issues.
Date Sun, 02 Apr 2006 15:57:41 GMT

2 things:

1.  You should *always* define the root logger, such as...

log4j.rootLogger=WARN, SomeAppender

2.  Your other loggers need to be prefixed by "log4j.logger.", such as...

log4j.logger.tb.test=DEBUG, SO1, RF1
log4j.logger.org.apache.commons.httpclient.wire=WARN, SO1, RF1


Jake

At 04:25 AM 4/2/2006, you wrote:
 >Usually putting log4j.properties in the classpath is enough to
 >properly initialize it.  In this case, even though log4j.properties is
 >provably in my classpath, it's not initializing correctly.
 >
 >
 >
 > Here is the code:
 >
 > package tb.test;
 >
 > import org.apache.log4j.Logger;
 > import java.io.File;
 >
 > public class SimpleInit {
 >
 >     private static final Logger logger = Logger.getLogger(SimpleInit.class);
 >
 >     public static void main(String[] args) throws Exception {
 >         String log4jfile = "log4j.properties";
 >         File l = new File(log4jfile);
 >
 >         // this proves log4j.properties is in the path
 >         System.out.println("Simple: " + log4jfile + " exists: " + 
l.exists());
 >         //org.apache.log4j.BasicConfigurator.configure();
 >         logger.info("Ahoy");
 >     }
 > }
 >
 >
 >
 > Here is the output:
 > Simple: log4j.properties exists: true
 > log4j:WARN No appenders could be found for logger (tb.test.SimpleInit).
 > log4j:WARN Please initialize the log4j system properly.
 >
 >
 >
 > Here is the log4j.properties:
 >
 > tb.test=DEBUG, SO1, RF1
 > httpclient.wire=WARN, SO1, RF1
 >
 > # SO1 appender
 > log4j.appender.SO1=org.apache.log4j.ConsoleAppender
 > log4j.appender.SO1.layout=org.apache.log4j.PatternLayout
 > log4j.appender.SO1.layout.ConversionPattern=%d{HH:mm:ss} [%16.16t]
 >[%X{stbip}] %-5p [%-6L:%-22.22c{1}] - %m%n
 > log4j.appender.SO1.threshold=INFO
 >
 > #RF1 appender
 > log4j.appender.RF1=org.apache.log4j.RollingFileAppender
 > log4j.appender.RF1.File=log/test.log
 > log4j.appender.RF1.MaxFileSize=10000KB
 > log4j.appender.RF1.MaxBackupIndex=9
 > log4j.appender.RF1.Append=false
 > log4j.appender.RF1.layout=org.apache.log4j.PatternLayout
 > #log4j.appender.RF1.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %-5p
 >[%t] [%X{stbip}] [%C{1} (%L)]: %m%n
 > log4j.appender.RF1.layout.ConversionPattern=%d{dd MMM HH:mm:ss}
 >[%16.16t] [%X{stbip}] %-5p [%-6L:%-22.22c{1}] - %m%n
 >
 >
 >
 > Any suggestions appreciated!
 >
 > Thanks!
 >
 >
 > -Travis
 >
 >
 >
 >---------------------------------
 >How low will we go? Check out Yahoo! Messenger's low  PC-to-Phone call rates.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message