Creating a log file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Arockia_Hanson
Posted On:   Monday, July 21, 2003 02:13 AM

Hi!!
I would like to create seperate log files for fatal error , and debug...

Where and how should I acheive this When using log4j..

Thanks in advance..

Re: Creating a log file

Posted By:   Thomas_Hackel  
Posted On:   Monday, July 21, 2003 04:11 AM

generally this is easy to archive. in the log4j config file declare two different log levels for the same category and use two different appenders:



log4j.logger.com.package.classORpackage=DEBUG, Appender1
log4j.logger.com.package.classORpackage=FATAL, Appender2


Declare two appenders:



log4j.appender.Appender1=org.apache.log4j.RollingFileAppender
log4j.appender.Appender1.File=/temp/debuglog.log
log4j.appender.Appender1.MaxFileSize=100MB
log4j.appender.Appender1.MaxBackupIndex=0
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.Appender2=org.apache.log4j.RollingFileAppender
log4j.appender.Appender2.File=/temp/fatallog.log
log4j.appender.Appender2.MaxFileSize=100MB
log4j.appender.Appender2.MaxBackupIndex=0
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%d %p [%c] - %m%n


In the dbuglog.log file there will be all output with level debug AND higher (also FATAL!) and in the fatallog.log there will be only messages with the level FATAL (or higher even no default Level is higher).


Better use XML configuration files instead of a properties file.

About | Sitemap | Contact