Exempt a given class not to write into my log file using Log4J properties file
I am using log4j to do my logging.
I lately added a library (Connection pooling lib called DBPool) and it is producing a lot of output to my log file. The log file reaches its max file size in less than 30minutes.
The excessive output to my log file is also making my debugging very hard because I cannot see easily locate my lines of interest in the log file is hindering me from debugging my code.
My question is, How do I exempt a given class from writing in my log file using log4j?
Here is my log4.properties file's contents.
log4j.rootCategory=DEBUG, dailyApp
log4j.rootCategory=DEBUG, dailyApp
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-4r [%t] %-5p %c{2} %x - %m%n
log4j.appender.dailyApp=org.apache.log4j.RollingFileAppender
log4j.appender.dailyApp.File=logs/myLog.log
log4j.appender.dailyapp.MaxFileSize=1024KB
log4j.appender.dailyApp.MaxBackupIndex=5
log4j.appender.dailyApp.layout=org.apache.log4j.PatternLayout
log4开发者_C百科j.appender.dailyApp.layout.ConversionPattern=%d %-4r [%t] %-5p %c{2} %x - %m%n
log4j.logger.httpclient=INFO
log4j.logger.org.apache.commons.httpclient=INFO
The class I do not want to log into logs/myLog.log is snaq.db.ConnectionPool
Thanks.
As far as I know the following should work, like with the two INFO
levels at the bottom of your configuration.
log4j.logger.some.package.name=OFF
Adding this line
log4.logger.snaq.db = ERROR
should help
Adding this line to the configuration file should work:
log4j.snap.db.ConnectionPool=ERROR
This will not disable logging for instances of this class but set the minimum level to error.
精彩评论