Reputation: 5380
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.
Upvotes: 6
Views: 22588
Reputation: 72
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>
Upvotes: 0
Reputation: 80342
In my particular case, I got this error in IntelliJ IDEA
, and refreshing Gradle fixed this error:
You can find this window from View..Tool Windows..Gradle
.
Our setup is:
Upvotes: 5
Reputation: 611
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).
Upvotes: 3
Reputation: 719239
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.
Upvotes: 2