Multiple SLF4J bindings with Play 2.3.8

Valentyn Danylchuk

I use Play Framework 2.3.8 (for Java) with Scala 2.11.

I get this warning:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/vdanylchuk/.ivy2/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/vdanylchuk/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

This causes real problems at run time in a random way. On some of the deployed hosts, all goes well and the logs are written as configured. On the other hosts, the wrong binding wins, and the logs are written in the wrong location. The deployment process is scripted and exactly the same. So the warning at http://www.slf4j.org/codes.html#multiple_bindings is correct, and this is random, so I need to remove the extra binding.

The fun thing is, they both come from the Play framework. logback-classic (which I actually want to use) comes from the play library, and slf4j-simple comes from the play sbt plugin.

I read a lot of similar questions here and in the mailing lists. Example: How to fix "SLF4J: Class path contains multiple SLF4J bindings" at startup of Play 2.3.x? The common solution is to use some form of exclude rules. None of the suggested solutions worked for me. [Update: in fact, they do - see the solution below.] I would not expect slf4j-simple to come up in the final classpath, but it does. Even though I added excludeAll(ExclusionRule(organization = "org.slf4j")) to every single dependency in my project, except the play framework.

Any ideas on how to get rid of slf4j-simple? Preferably on sbt project level, without manually cleaning up the classpath of the build result.

Update: instructions to reproduce

I have narrowed it down with a small test project. Turns out it is triggered by a combination of play sbt plugin and the aether-deploy plugin that we use. It is sufficient to have this small configuration.
build.sbt:

name := "slf4j-test"
version := "1.0"
scalaVersion := "2.11.5"
lazy val root = (project in file(".")).enablePlugins(PlayJava)


project/plugins.sbt:

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")
addSbtPlugin("no.arktekk.sbt" % "aether-deploy" % "0.13")


project/build.properties:

sbt.version=0.13.7

Then just run "sbt test:compile" or "sbt run" (and query localhost:9000) to see the warning. It works the same with scala 2.10.

Valentyn Danylchuk

My bad. In the end, a simple exclusion in project/plugins.sbt fixed this:

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

I tried this earlier, but apparently made a syntax mistake, and thought this was not supported. facepalm

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to fix "SLF4J: Class path contains multiple SLF4J bindings" at startup of Play 2.3.x?

From Dev

Maven SLF4J: Class path contains multiple SLF4J bindings

From Dev

Apache Storm: SLF4J: Class path contains multiple SLF4J bindings

From Dev

Websphere Multiple slf4j logback bindings work around

From Dev

Class path contains multiple SLF4J bindings with Gradle

From Dev

Multiple SLF4J bindings cause error?

From Dev

Spring + PostgreSQL > Multiple SLF4J bindings

From Dev

SLF4J: Class path contains multiple SLF4J bindings. message printed on console

From Dev

How to exclude multiple SLF4J bindings to LOG4J

From Dev

SLF4J: No Binder, and then Multiple Bindings, trying to Bind to Log4J

From Dev

Class path contains multiple SLF4J bindings after exclusion

From Dev

Class path contains multiple SLF4J bindings (can't found it)

From Dev

"SLF4J: Class path contains multiple SLF4J bindings" error when deploying the Spring example application to Cloud Foundry

From Dev

"SLF4J: Class path contains multiple SLF4J bindings" error when deploying the Spring example application to Cloud Foundry

From Dev

Class path contains multiple SLF4J bindings, log back-classic and log4j

From Dev

Class path contains multiple SLF4J bindings, log back-classic and log4j

From Dev

When i try to install Hive 2.0 i get a multiple SLF4J bindings and that Hive metastore database is not initialized

From Dev

using slf4j with log4j2

From Dev

How to enable Log4j on SpringBoot Gradle: log4j-over-slf4j.jar, slf4j-log4j12.jar Multiple Bindings

From Dev

PropertiesLauncher working differently with slf4j bindings in newer version of spring boot

From Dev

Play/Scala 2.5 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

From Dev

what is the difference between Log4j 2 SLF4J Binding and Log4j 2 to SLF4J Adapter

From Dev

Axis2 webservice with multiple soap bindings

From Dev

Using log4j2 with slf4j: java.lang.StackOverflowError

From Java

Is it worth to use slf4j with log4j2

From Dev

Bridging from log4j2 to slf4j

From Dev

How to configure a Gradle application to use SLF4J with a Log4J 2 implementation?

From Dev

Log4j (SLF4J) MDC Context in Struts 2 Interceptor

From Dev

How to send email notifications with slf4j / log4j2?

Related Related

  1. 1

    How to fix "SLF4J: Class path contains multiple SLF4J bindings" at startup of Play 2.3.x?

  2. 2

    Maven SLF4J: Class path contains multiple SLF4J bindings

  3. 3

    Apache Storm: SLF4J: Class path contains multiple SLF4J bindings

  4. 4

    Websphere Multiple slf4j logback bindings work around

  5. 5

    Class path contains multiple SLF4J bindings with Gradle

  6. 6

    Multiple SLF4J bindings cause error?

  7. 7

    Spring + PostgreSQL > Multiple SLF4J bindings

  8. 8

    SLF4J: Class path contains multiple SLF4J bindings. message printed on console

  9. 9

    How to exclude multiple SLF4J bindings to LOG4J

  10. 10

    SLF4J: No Binder, and then Multiple Bindings, trying to Bind to Log4J

  11. 11

    Class path contains multiple SLF4J bindings after exclusion

  12. 12

    Class path contains multiple SLF4J bindings (can't found it)

  13. 13

    "SLF4J: Class path contains multiple SLF4J bindings" error when deploying the Spring example application to Cloud Foundry

  14. 14

    "SLF4J: Class path contains multiple SLF4J bindings" error when deploying the Spring example application to Cloud Foundry

  15. 15

    Class path contains multiple SLF4J bindings, log back-classic and log4j

  16. 16

    Class path contains multiple SLF4J bindings, log back-classic and log4j

  17. 17

    When i try to install Hive 2.0 i get a multiple SLF4J bindings and that Hive metastore database is not initialized

  18. 18

    using slf4j with log4j2

  19. 19

    How to enable Log4j on SpringBoot Gradle: log4j-over-slf4j.jar, slf4j-log4j12.jar Multiple Bindings

  20. 20

    PropertiesLauncher working differently with slf4j bindings in newer version of spring boot

  21. 21

    Play/Scala 2.5 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

  22. 22

    what is the difference between Log4j 2 SLF4J Binding and Log4j 2 to SLF4J Adapter

  23. 23

    Axis2 webservice with multiple soap bindings

  24. 24

    Using log4j2 with slf4j: java.lang.StackOverflowError

  25. 25

    Is it worth to use slf4j with log4j2

  26. 26

    Bridging from log4j2 to slf4j

  27. 27

    How to configure a Gradle application to use SLF4J with a Log4J 2 implementation?

  28. 28

    Log4j (SLF4J) MDC Context in Struts 2 Interceptor

  29. 29

    How to send email notifications with slf4j / log4j2?

HotTag

Archive