| Author |
Is there any way to change root logger for different appenders in the same log4.properties file
|
Abhijit Kangale
Ranch Hand
Joined: Sep 17, 2009
Posts: 37
|
|
Hi,
I have used log4j framework in my application with below log4j.properties file configuration.
#Console appender
log4j.rootLogger=DEBUG, stdout, rollFile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern= [%5p] %d{mm:ss} (%F:%M:%L)%n%m%n%n
#Rolling file appender
log4j.appender.rollFile=org.apache.log4j.RollingFileAppender
log4j.appender.rollFile.File=Out.txt
log4j.appender.rollFile.MaxFileSize=10MB
log4j.appender.rollFile.MaxBackupIndex=1
log4j.appender.rollFile.Append=true
log4j.appender.rollFile.layout=org.apache.log4j.PatternLayout
log4j.appender.rollFile.layout.ConversionPattern= %d [ %-5p ] %c | %m | %t | %x %n
Here I can use only single root logger. But if I want to use different root logger for different appenders (like for ConsoleAppender -DEBUG and for RollingFileAppender - ERROR), is there any way to implement such approach?
Thanks in advance,
Abhijit
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
I can understand why you want to use different loggers, but why different root loggers? You're just making things hard for yourself if you try to do things which can't be done. Just use different loggers and skip the root logger entirely if you don't need it.
|
 |
 |
|
|
subject: Is there any way to change root logger for different appenders in the same log4.properties file
|
|
|