SLF4J Warning: Class Path Contains Multiple SLF4J Bindings | Baeldung
The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks. Thus, it allows us to plug in our desired logging framework at deployment time.
To achieve this, SLF4J looks for bindings (a.k.a providers) on the classpath. Bindings are basically implementations of a particular SLF4J class meant to be extended to plug in a specific logging framework.
By design, SLF4J will only bind with one logging framework at a time. Consequently, if more than one binding is present on the classpath, it will emit a warning.
It is worth noting that embedded components such as libraries or frameworks should never declare a dependency on any SLF4J binding. This is because when a library declares a compile-time dependency on an SLF4J binding, it imposes that binding on the end-user. Obviously, this negates SLF4J's basic purpose. Consequently, they should only depend on the slf4j-api library.
It is also important to note that this is only a warning. If SLF4J finds multiple bindings, it will pick one logging framework from the list and bind with it. As can be seen on the last line of the warning, SLF4J has chosen Log4j by using org.slf4j.impl.Log4jLoggerFactory for the actual binding.
Read full article from SLF4J Warning: Class Path Contains Multiple SLF4J Bindings | Baeldung
No comments:
Post a Comment