tags:

views:

66

answers:

3

Hi,

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
log4j.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.

+3  A: 

Adding this line

log4.logger.snaq.db = ERROR

should help

JoseK
so you were 10 seconds faster ;)
Johannes Wachter
+4  A: 

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
Johannes Wachter
well we win some :)
JoseK
Thanks, Johannes Wachter, That worked exactly as I wanted.
mwangi
+2  A: 

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.

Andreas_D