excluding log4j from third party jar in pom
maven, pom.xml, spring
Solution
This is the correct answer from https://www.baeldung.com/slf4j-classpath-multiple-bindings
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
Problem
I am creating a webservice which hits existing business code. The required jar which deals with logging is org.ops4j.pax.logging. I have include this in the pom ``` <dependency> <groupId>org.ops4j.pax.logging</groupId> <artifactId>pax-logging-api</artifactId> <version>1.6.0</version> </dependency> ``` This jar allows access to a particular log4j method which is used throughout the business layer ``` LOGGER.debug(object, object); ``` One of the other required jars is a third party jar. This jar contains a different version of log4j which does not implement the debug(object, object) method. When I add this jar to the pom, the JVM finds the log4j classes in this third party jar first and the code falls over. I have tried to exclude the log4j in the third party jar but to no avail. ``` <dependency> <groupId>...</groupId> <artifactId>...</artifactId> <version>...</version> <exclusions> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> </exclusions> </dependency> ``` Any thoughts?