You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Rich Gibbs <ri...@enhansiv.com> on 2002/12/06 04:26:43 UTC
PropertyConfigurator problem
Sorry about the bad subject line...
-----Original Message-----
From: Rich Gibbs
Sent: Thursday, December 05, 2002 7:24 PM
To: 'Log4J Developers List'
Subject: RE: Rolling appender, that contains standard err/out
I just came across this in the 1.2.7 release similar code ran without a
problem in the 1.0.2 release I believe...
The output is as follows:
0 [main] INFO testing.Main - The log object is org.apache.log4j.Logger
10 [main] INFO testing.Main - Starting main()
10 [main] INFO testing.Main - init(1)...
It seems that calling the PropertyConfigurator with a String, or just
properties after some categories are initialized, causes the initial
categories to not print any longer.
Any ideas? I looked through the bug database, but I did not see anything
that looked related...
Thanks
Rich
package testing;
import org.apache.log4j.*;
/**
*
* Test Basic initialization, prior to initializing based on a specific
* application file.
*/
public class Main {
/*
* The category to be used in this class for testing purposes...
* In the real life example, the category at this level is static
and initialized
* here. Additonal categories are initialized for every class, but
the
* actual properties path can't be determined till later, at which
point it
* needs to be used.
*/
private static Category log;
static
{
BasicConfigurator.configure();
log = Category.getInstance(Main.class );
log.info("The log object is " + log.getClass().getName());
}
public static void main(String[] args) {
log.info( "Starting main()" );
Main m = new Main();
m.init();
log.info( "Still works" );
}
private void init()
{
log.info( "init(1)..." );
Category log2 = Category.getInstance(Main.class);
String logPropertiesPath = "J:\\log4jTesting\\log.properties";
PropertyConfigurator.configure(logPropertiesPath);
log.info( "init(2)..." );
log.info( "does log still work?" );
PropertyConfigurator.configureAndWatch( logPropertiesPath );
log.debug( "3 logPropertiesPath(realPath)=" + logPropertiesPath );
}
}
The contents of the log.properties file...
log4j.rootCategory=WARN, stdout
#log4j.debug=true
# stdout is set to be a ConsoleAppender.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout=org.apache.log4j.FileAppender
#log4j.appender.stdout.File=System.out
# stdout uses PatternLayout.
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
#struts debugging
log4j.category.org.apache.struts=WARN
#enhansiv debugging
log4j.category.com.enhansiv=DEBUG