I'm getting the following error. It seems there are multiple logging frameworks bound to sl4j. Not sure how to resolve this. Any help is greatly appreciated.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/admin/.m2/repository/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/admin/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
The error probably gives more information like this (although your jar names could be different)
Noticed that the conflict comes from two jars, named
logback-classic-1.2.3
andlog4j-slf4j-impl-2.8.2.jar
.Run
mvn dependency:tree
in this project pom.xml parent folder, giving:Now choose the one you want to ignore (could consume a delicate endeavor I need more help on this)
I decided to not use the one imported from
spring-boot-starter-data-jpa
(the top dependency) throughspring-boot-starter
and throughspring-boot-starter-logging
, pom becomes:in above pom
spring-boot-starter-data-jpa
would use thespring-boot-starter
configured in the same file, which excludeslogging
(it containslogback
)Sbt version:
Append
exclude("org.slf4j", "slf4j-log4j12")
to the dependency that transitively includesslf4j-log4j12
. For example, when using Spark with Log4j 2.6:Gradle version;
... org.codehaus.mojo cobertura-maven-plugin 2.7 test ch.qos.logback logback-classic tools com.sun ...
## I fixed with this
... org.codehaus.mojo cobertura-maven-plugin 2.7 test ch.qos.logback logback-classic tools com.sun ...
Seems removing .m2 directory and :
mvn install -DskipTests -T 4
resolved this issue for me.For me, it turned out to be an Eclipse/Maven issue after switch from log4j to logback. Take a look into your
.classpath
file and search for the string"log4j"
.In my case I had the following there:
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.7.1/slf4j-log4j12-1.7.1.jar"/> <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.17/log4j-1.2.17.jar" />
Removing those entries from the file (or you could regenerate it) fixed the issue.