dcsimg
Log4j Multiple FileAppenders
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, December 12, 2002 12:55 AM

I am using single FileAppender for all logging messages. Now,I want to use multiple FileAppenders for the same web-application. I am using RollingFileAppender. Here is my log4j.properties file. log4j.rootLogger=debug, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=${tone.logHome}/toneLog4j.log log4j.appender.R.MaxFileSize=2MB log4j.appender.R.MaxBackupIndex=2 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%5p %d{dd MMM yyyy HH:mm:ss} (%F:%L) - %m%n log4j.appender.R.Threshold=INFO    More>>

I am using single FileAppender for all logging messages. Now,I want to use multiple FileAppenders for the same web-application. I am using RollingFileAppender.

Here is my log4j.properties file.



log4j.rootLogger=debug, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${tone.logHome}/toneLog4j.log
log4j.appender.R.MaxFileSize=2MB
log4j.appender.R.MaxBackupIndex=2
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p %d{dd MMM yyyy HH:mm:ss} (%F:%L) - %m%n
log4j.appender.R.Threshold=INFO

   <<Less

Re: Log4j Multiple FileAppenders

Posted By:   Anonymous  
Posted On:   Thursday, December 12, 2002 07:23 AM

The define more than one.

log4j.rootLogger=debug, R, S
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${tone.logHome}/toneLog4j.log
log4j.appender.R.MaxFileSize=2MB
log4j.appender.R.MaxBackupIndex=2
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p %d{dd MMM yyyy HH:mm:ss} (%F:%L) - %m%n

log4j.appender.R.Threshold=INFO
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${tone.logHome}/secondLog4j.log
log4j.appender.R.MaxFileSize=2MB
log4j.appender.R.MaxBackupIndex=2
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p %d{dd MMM yyyy HH:mm:ss} (%F:%L) - %m%n
log4j.appender.R.Threshold=INFO


But in this case ALL messages are logged into BOTH files. For splitting you have to use categories.

...
log4j.logger.category-name=threshold appender-names
About | Sitemap | Contact