Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable log4j console logging and enable file logging

My log4j.properties file is:

log4j.rootLogger=WARN, stdout, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %p [%c] - %m%n

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${jboss.server.log.dir}/afrodite.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d [%t] %p [%c] - %m%n

log4j.logger.info.release.scheduler=INFO, scheduler
log4j.appender.scheduler=org.apache.log4j.RollingFileAppender
log4j.appender.scheduler.File=${jboss.server.log.dir}/afrodite_scheduler.log
log4j.appender.scheduler.MaxFileSize=10MB
log4j.appender.scheduler.MaxBackupIndex=10
log4j.appender.scheduler.Append=true
log4j.appender.scheduler.layout=org.apache.log4j.PatternLayout
log4j.appender.scheduler.layout.ConversionPattern=%d [%t] %p [%c] - %m%n 

If I want to disable console output for scheduler logger what should I do? That means scheduler logger only log into file not in console.

Thanks and Regards.

like image 767
Tapas Bose Avatar asked May 23 '11 10:05

Tapas Bose


2 Answers

Add this line to your config:

log4j.appender.scheduler.additivity=false

log4j.additivity.info.release.scheduler=false

(sorry, first hint was incorrect.)

like image 178
Péter Török Avatar answered Oct 06 '22 19:10

Péter Török


you can add two lines in your properties file.

log4j.rootLogger=ALL, stdout, file,scheduler   (#here ALL declare for all level of logs)

log4j.logger.info.release.scheduler=INFO, scheduler
log4j.additivity.info.release.scheduler=false
like image 32
madhu Avatar answered Oct 06 '22 17:10

madhu