Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 210
mjn Avatar asked Feb 09 '11 18:02

mjn


People also ask

Is Commons logging using log4j?

Jakarta Commons logging is a wrapper around Log4j (Log4jLogger), the Java native logging system(Jdk14Logger) and the built-in fall-back logger SimpleLog. Depending on which one is on the classpath, that logging system is addressed transparently via the easy-to-learn commons logging API.

Is Apache Commons Logging same as log4j?

log4j is a logging framework, i.e. it provides the code to log messages. Commons-logging is an abstraction layer for logging frameworks, it doesn't log anything itself.


2 Answers

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.

like image 198
Axel Fontaine Avatar answered Sep 28 '22 07:09

Axel Fontaine


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

like image 26
hvgotcodes Avatar answered Sep 28 '22 07:09

hvgotcodes