dcsimg
Custom Appender - Does't work for complete package
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Muhammad_Shahid
Posted On:   Tuesday, June 30, 2009 04:22 AM

I am using log4j.properties to log in different files for each modules. Each module is defined in the log4j.properties as log4j.logger.com.log.test.one=DEBUG, com.log.test.one log4j.logger.com.log.test.two=DEBUG, comlog.test.two log4j.appender.com.log.test.one=org.apache.log4j.FileAppender log4j.appender.com.log.test.one.File=one.log log4j.appender.com.log.test.one.layout=org.apache.log4j.PatternLayout log4j.appender.com.log.test.one.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - %m%n log4j.appender.com.log.test.two=org.apache.log4j.FileAppender log4j.appender.com.log.test.two.File=two.log log4j.appender.com.log.test.two.layout=org.apache.log4j.PatternLayout    More>>

I am using log4j.properties to log in different files for each modules. Each module is defined in the log4j.properties as

log4j.logger.com.log.test.one=DEBUG, com.log.test.one
log4j.logger.com.log.test.two=DEBUG, comlog.test.two

log4j.appender.com.log.test.one=org.apache.log4j.FileAppender
log4j.appender.com.log.test.one.File=one.log
log4j.appender.com.log.test.one.layout=org.apache.log4j.PatternLayout
log4j.appender.com.log.test.one.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - %m%n

log4j.appender.com.log.test.two=org.apache.log4j.FileAppender
log4j.appender.com.log.test.two.File=two.log
log4j.appender.com.log.test.two.layout=org.apache.log4j.PatternLayout
log4j.appender.com.log.test.two.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - %m%n

Now,
what i want a module to read some properties from a properties file as follow for a module "com.log.test".

log4j.logger.com.log.test= DEBUG, com.log.test
log4j.appender.com.log.test=org.apache.log4j.FileAppender
log4j.appender.comlog.test.maxFileSize=100KB
log4j.appender.comlog.test.File=file_appender.log
log4j.appender.comlog.test.Append=false
log4j.appender.comlog.test.layout=org.apache.log4j.PatternLayout
log4j.appender.comlog.test.layout.ConversionPattern=%p %t %c - %m%n


Create a FileAppender object, add this to the Logger.getLogger().addAppender();

what i need here is to add this appender once at the loading of this particular module and every class in this module when gets the Logger it logs to the file specified for "com.log.test"

It does not because it only does it for the class in which i create and add appender, for other classes it does not find any logger.

   <<Less
About | Sitemap | Contact