mjn
mjn

Reputation: 36664

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.

Upvotes: 6

Views: 4790

Answers (3)

Pablojim
Pablojim

Reputation: 8582

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.

Upvotes: 0

hvgotcodes
hvgotcodes

Reputation: 120308

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

Upvotes: 1

Axel Fontaine
Axel Fontaine

Reputation: 35179

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.

Upvotes: 10

Related Questions