Filtering out log4j messages from third-party frameworks?

In my log4j.properties file I set the root logger logging level to ERROR. Then for packages I specifically want to log, like my application code, I set the logging level to INFO or DEBUG.

log4j.rootLogger=ERROR, stdout
log4j.logger.com.initech.tps=DEBUG
log4j.logger.org.hibernate.SQL=INFO

I see co-workers who set root logging low and then end up listing everything they don’t want to see, that just seems backward to me. I would rather list what I want to log than all the things I don’t want to log.

BTW turning logging off entirely for a third-party component seems like a bad idea to me. For instance, Spring is relatively noisy and uses WARN for things I really don’t need to know about, but if it logs an ERROR entry for something I want to see it.

Leave a Comment