File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there any way to change root logger for different appenders in the same log4.properties file

 
Abhijit Kangale
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20184
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic