Search code examples
javawarningsslf4j

How to get rid of the "Class path contains multiple SLF4J bindings" warning?


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.


Solution

  • 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).