5

This is more-or-less a "common" question, however, I haven't managed to find a good answer yet. So, again, here is the warning:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/eualin/.m2/repository/org/slf4j/slf4j-jcl/1.6.0/slf4j-jcl-1.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/eualin/.m2/repository/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

And here are two potential solutions to the problem [1][2].

Assuming that they will both work for me, obviously, they are just hacks, and I am not sure if I should rely on any of them at all. What would you recommend me? Keep in mind that the warning does not appear when in terminal; only when I run the application through IntelliJIDEA.

Any suggestion is highly appreciated.

Community
  • 1
  • 1
user706838
  • 5,132
  • 14
  • 54
  • 78

4 Answers4

4

In my particular case, I got this error in IntelliJ IDEA, and refreshing Gradle fixed this error:

enter image description here

You can find this window from View..Tool Windows..Gradle.

Our setup is:

  • IntelliJ IDEA v15
  • Gradle
  • Jenkins
  • SVN
Contango
  • 76,540
  • 58
  • 260
  • 305
3

SLF4J expects only one version of StaticLoggerBinder to be present in any application runtime. If there is more than one, SLF4J cannot guarantee that log messages will be routed to the appropriate logger.

The architecture of SLF4J requires that only one library be used to route log messages (e.g. slf4j-<logging framework>.jar). When multiple classpath's are in play via application servers, IDE's, startup scripts, etc., SLF4J libraries can get included multiple times. You may have to hunt and peck to find where classpath's are either being added or modified in IntelliJIDEA (such as in the configured Java compilers or in any startup configurations).

Snapman
  • 601
  • 5
  • 11
2

It is presumably happening because IntelliJIDEA is adding one of those slf4j binding JARs itself. My guess is happening when you run unit tests. So one approach would see if you can exclude the other JAR in the launcher configs for the the Unit test runner.

But at the end of the day, this warning is harmless, and you could simply ignore it.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • No, I am not trying to run a unit test for this application; I am just trying to run the application itself. At the end, I will probably ignore it, may I ask you about further ideas on how to get rid of it, preferably without touching the other jar file at all? – user706838 Feb 18 '13 at 15:56
  • This is clearly a runtime classpath issue. You need to make sure that the IntelliJIDEA is not putting both JARs on the classpath when launching your application. I'd start by looking at the POM file and the dependencies that it specifies. – Stephen C Feb 18 '13 at 23:05
0

In the project's pom.xml file, set the needed logging backend by default in the list of found dependencies by adding to your project as a direct dependency on it, for example :

<dependency>
    <groupid>ch.qos.logback</groupid>
    <artifactid>logback-classic</artifactid>
    <scope>runtime</scope>
</dependency>
SternK
  • 11,649
  • 22
  • 32
  • 46
Mad Calm
  • 52
  • 4