Multiple SLF4J bindings with Play 2.3.8

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

I get this warning:

SLF4J: the class path contains several 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 leads to real run-time problems in an arbitrary way. On some of the deployed hosts, everything is going well, and the logs are recorded according to the settings. On other hosts, the wrong binding wins, and the logs are written in the wrong place. 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 a random value, so I need to remove the extra binding.

The most interesting thing is that they both come from the Play platform. logback-classic (which I really want to use) comes from the playback library, and slf4j-simple comes from the sbt plugin for the game.

I read a lot of similar questions here and on the mailing lists. Example: How to fix "SLF4J: class path contains many SLF4J bindings" when starting game 2.3.x? A common solution is to use some exclusion rules. None of the proposed solutions worked for me. [Update: in fact, they do this - see the solution below.] I would not expect slf4j-simple to appear in the last class path, but it is. Although I added excludeAll (ExclusionRule (organization = "org.slf4j")) for every single dependency in my project, except for the playback frame.

Any ideas on how to get rid of slf4j-simple? Preferably at the sbt project level, without manually clearing the path to the build result class.

Update: instructions for playback

I narrowed it down to a small test project. It turns out that this is caused by a combination of the sbt plugin for the game and the ether deployment plugin that we use. It is enough 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 request localhost: 9000) to see a warning. It works the same way with Scala 2.10.

+7
scala playframework sbt aether
source share
1 answer

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

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

I tried this before, but apparently made a syntax error and thought it was not supported. Facepalm

+6
source share

All Articles