Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering out log4j messages from third-party frameworks?

How do I filter log messages from external third party frameworks? I am using Hibernate and Spring framework and I would like to suppress the logs so that only my log4j logs appears.

like image 404
walters Avatar asked Aug 25 '10 19:08

walters


People also ask

What is a log4j filter?

</RollingFile> </Appenders> <Loggers> <Root level="error"> <AppenderRef ref="RollingFile">

Can you disable log4j?

If you are on a version of Log4J newer than 2.10. 0, you can disable JNDI lookups using the following settings: System property LOG4J_FORMAT_MSG_NO_LOOKUPS to true. OR Environment variable log4j2.

Does Python logging use log4j?

log4j is a popular logging package written in Java. log4j has been ported to the C, C++, C#, Perl, Python, Ruby, and Eiffel languages.

What are logging filters?

Log filters help control more detailed logging settings that are not handled by usual log level settings. A filter provides an optional, secondary control over what is logged, beyond the control that is provided by setting the level.


1 Answers

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.

like image 109
Nathan Hughes Avatar answered Oct 05 '22 03:10

Nathan Hughes