sbt exclusion slf4j not working

slf4j-log4j12
slf4j sbt
sbt exclude dependency
sbt exclude multiple dependencies
sbt evicted
sbt dependency override
sbt dependency conflict resolution
sbt classifier tests

I have a third party dependency in my play project. That third party library has eventual dependency ( not direct ) on an slf4j implementation.

I am getting duplicate binding error for slf4j.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:~/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/~/.ivy2/cache/com.orgname.platform/platform-logging-client/jars/platform-logging-client-2.5.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]

I tried following things but can get rid of the error.

"com.orgname.platform" % "platform-metric-client" % "1.0.4" excludeAll(
    ExclusionRule(organization = "org.slf4j"))

I also tried following exclusion

"com.orgname.platform" % "platform-metric-client" % "1.0.4" exclude("org.slf4j","slf4j-jdk14)

and also this one

 "com.orgname.platform" % "platform-metric-client" % "1.0.4" exclude("org.slf4j","slf4j-log4j12)

Since I was not able to remove the slf4j from third party dependency I, tired to remove the play dependency on slf4j, by modifying projcts/plugin.sbt

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6" exclude("org.slf4j", "slf4j-simple"))

How should I go about getting rid of this warning. how does this warning impact the logging? Which logging implementation would be used the Scala implementation?

The answer by YourBestBet is correct, but you can save yourself some copy-pasting by mapping the sequence of imports with the excludes.

//dependencies with exclusions
libraryDependencies ++= Seq(
    //depencies
).map(_.exclude("org.slf4j", "*"))

//insert one without exclusion
libraryDependencies ++= Seq(
  "ch.qos.logback" % "logback-classic" % "1.1.3"
)

EDIT:

I suggest investing some time and understanding transitive dependencies and scope management. It will save you time in the future. Maven has a great and straightforward doc page about it: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

PS. Exclude? Provided?

sbt exclusion slf4j not working - scala - html, sbt exclusion slf4j not working - scala. That third party library has eventual dependency ( not direct ) on an slf4j implementation. I am getting duplicate binding  The first thing you need to do is edit the /project/plugins.sbt file and add the latest version of sbt-plugin in the addSbtPlugin section. Now, delete the ivy directory present at ~/.ivy2 Then, go ahead and delete the below mentioned files: <path to Play Framework home directory>/.sbt.ivy.lock <path to Play Framework home directory>/cache/org.slf4j

IMHO, No matter exclude or excludeAll , it only excludes slf4j dependency from THAT library, not excluding slf4j dependency from the whole project. Thus, all library dependencies lines which may transitively depend on slf4j need to add exclude("org.slf4j","slf4j-log4j12).

A quick and dirty solution is to append exclude("org.slf4j","slf4j-log4j12) to each libraryDepencies line. I tried this, it worked for me.

Excluding Spark SLF4J transitive dependencies in sbt, Excluding Spark SLF4J transitive dependencies in sbt bytes result sent to driver [dispatcher-event-loop-2] INFO org.apache.spark.scheduler. Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.

Tell SBT that SLF4J is provided and SBT won't add it to the classpath. To do that, add the following to libraryDependencies:

"org.slf4j" % "slf4j-simple" % "1," Provided

It is possible that various dependencies (or their transitive dependencies) might reference SLF4J with varying versions. That is why I used an Ivy version range matcher. You might find that the actual version matcher you need is some variation of what I wrote.

Use logback with slf4j in sbt custom tasks (override default , Use logback with slf4j in sbt custom tasks (override default this: // excludeDependencies += ExclusionRule("org.apache.logging.log4j", "log4j-slf4j-​impl") problem. The LoggerFactory.getLogger returns a log4j logger but it  A bridge between sbt's plugin logger and SLF4j. Contribute to eirslett/sbt-slf4j development by creating an account on GitHub.

Both answers provided by @YourBestBet and @goozez are correct if your goal is to exclude the dependency from the project.

In my project , I had multiple dependencies that included slf4j and they conflicted with each other.

An easy fix (but tedious depending on the number of dependencies you have) is to exclude it from the conflicting dependency manually instead of removing it entirely from the project as you might need it.

  "org.elasticsearch" % "elasticsearch" % esVersion exclude("org.slf4j", "*"),

Plugin dependencies include multiple slf4j bindings · Issue #107 , GitHub is home to over 50 million developers working together to I'll try removing the other two plugins as well as the exclude , exiting sbt,  libraryDependencies ~= { .map(.exclude("org.slf4j", "slf4j-simple")) } The problem is: I have to add this line in each build.sbt (with the buggy dep) as well as in the CommonBuild. I thought having the exclude in the CommonBuild (or at least in the parent build.sbt) would be sufficient due to projects inheritance.

SLF4J Binding Using Log4j – Dependency Information, sbt version is 1.0.2. pasting the whole error might be more helpful: SLF4J: Class path contains so, do I have any chance to solve my problem? so you're sugegsting to disable log4j from play instead of excluding the one in the external jar. Hello Team, Can any one help me on the below issue regarding "Class path contains multiple SLF4J bindings". My application: We need to execute the SCALA activity(JAR File) through Azure ADF Pipeline.

sbt/sbt, This earlier exception should provide more valuable information about the root cause of the problem. The method o.a.commons.logging.impl.SLF4FLogFactory#​  For instance, if you are using slf4j-api-1.5.6.jar, then you should also use slf4j-simple-1.5.6.jar, using slf4j-simple-1.4.2.jar will not work. At initialization time, if SLF4J suspects that there may be a version mismatch problem, it emits a warning about the said mismatch.

SLF4J Error Codes, lib directory. sbt will put these jars on the classpath during compilation, testing, running, and when using the interpreter. If your project requires a dependency that is not present in a repository, a direct To exclude certain transitive dependencies of a dependency, use the commons-logging is replaced by jcl-​over-slf4j Hello Team, Can any one help me on the below issue regarding "Class path contains multiple SLF4J bindings" My application: ===== We need to execute the SCALA activity(JAR File) through Azure ADF