How to centralize the logging configuration and use only log4j.properties?

I would like to configure logging in my application using log4j.properties and instruct (somehow) all third-party packages / modules to enter this configuration. Now they are written in different ways, and this is a mess: OpenEJB, Hibernate, Apache HttpClient, Jersey, etc. How can i do this? I want to work only with log4j .

+4
source share
1 answer

Use a framework that can redirect all kinds of logging frameworks to log4j : slf4j .

See Overcoming Deprecated APIs for an overview.

[Edit] Maven pom.xml for slf4j:

 <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> <!-- The usual exclusions here: javax.mail:mail, oro:oro --> </dependency> 
+5
source

All Articles