How can I disable Apache Commons / Log4J logging in third party libraries?

4.7k views Asked by At

Is there a Apache Commons / Log4J logging API method which can be used to disable all logging completely, even for loggers which are in third party libraries?

Background: I would like to use java.util.logging in a GlassFish v3 web application. However, a third party library in this web app uses Log4J logging and Apache Commons Logging. To save resources, this logging should be minimized or switched off.

3

There are 3 answers

1
Axel Fontaine On BEST ANSWER

Edit your log4j configuration and set the logging level to ERROR or FATAL

Example for Hibernate:

log4j.logger.org.hibernate=ERROR

This will dwarf the logging output to almost zero, leaving only critical error messages.

0
hvgotcodes On

you can just raise the log threshold by package for the external libraries. I don't know about turning it off.

0
Pablojim On

Have a look at http://www.slf4j.org/

It provides versions of log4j and commons logging libraries that route all the messages to a logging implementation of your choice.