Search code examples
javalog4japache-commons-logging

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


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.


Solution

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