Slf4j has some information in its guide on how to do this.
I think you want to exclude log4j
and commons-logging
from all your maven dependencies and load log4j-over-slf4j
and jcl-over-slf4j
. They are intended to replace log4j
and commons-logging
and contain the corresponding org.apache.log4j
and org.apache.commons.logging
classes to replace Logger
, Log
and friends. This will not reduce libraries, but will cause all log data to be sent via sl4fj
. If you do not get rid of the use of these classes (obviously), you cannot reduce the dependency on the slf4j
wrapper or the original.
If you want to use a single logging package instead, the correct way to do this is to switch to using commons-logging
, which was designed as a delegating log, and then use the slf4j-jcl
, which connects to commons-logging
.
For descendants, you exclude the dependency in this way for each of the dependencies, which requires log4j
.
<dependency> <groupId>.../groupId> <artifactId>...</artifactId> <version>...</version> <exclusions> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> </exclusions> </dependency>
source share