Different loggers, different behaviuor?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jan_Gifvars
Posted On:   Thursday, February 27, 2003 01:15 AM

I would like to use two different loggers, log4j.rootCategory=DEBUG, A1, FILE1 log4j.rootCategory.file1=DEBUG, FILE1, A1 log4j.rootCategory.file2=DEBUG, FILE2, A1 ... log4j.appender.FILE1.File=file1.log log4j.appender.FILE2.File=file2.log ... log4j.appender.FILE1=org.apache.log4j.FileAppender log4j.appender.FILE2=org.apache.log4j.RollingFileAppender tLogger = Logger.getLogger("log4j.rootCategory.file2"); tLogger.info(" some info logged to file "); log4j.rootCategory.file1 will log entries to a file named file1.log and the other logger log4j.rootCategory.file2 will log its entries to a file na   More>>

I would like to use two different loggers,


log4j.rootCategory=DEBUG, A1, FILE1
log4j.rootCategory.file1=DEBUG, FILE1, A1
log4j.rootCategory.file2=DEBUG, FILE2, A1

...

log4j.appender.FILE1.File=file1.log
log4j.appender.FILE2.File=file2.log

...

log4j.appender.FILE1=org.apache.log4j.FileAppender
log4j.appender.FILE2=org.apache.log4j.RollingFileAppender



tLogger = Logger.getLogger("log4j.rootCategory.file2");

tLogger.info(" some info logged to file ");


log4j.rootCategory.file1 will log entries to a file named file1.log and the other logger log4j.rootCategory.file2 will log its entries to a file named file2.log.

I expect that entries to a specific logger only occurs in its corresponding file.

This scenario doesn't work. at least not with the above property file. What happens is that every entry logged, no matter what logger it is logged to, will occur in file1.log. The file2.log isn't even created. If i do like this the file2.log will be created but containing every entry logged. So file1 and file2 will be identical.


log4j.rootCategory=DEBUG, A1, FILE1, FILE2


Is possible at all with log4j to do what I want to do?

I have seen a suggestion about setting additivity to false programmatically or in the properties file, but that only gives me an error like this "log4j not properly initialized".


Best regards,

Jan Gifvars

   <<Less
About | Sitemap | Contact