Skip to content

Slf4j Misuse #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Dec 7, 2015 · 5 comments
Closed

Slf4j Misuse #230

ghost opened this issue Dec 7, 2015 · 5 comments
Milestone

Comments

@ghost
Copy link

ghost commented Dec 7, 2015

Why does your jar have a StaticLoggerBinder in it?

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hugballs/.m2/repository/pl/project13/maven/git-commit-id-plugin/2.2.0/git-commit-id-plugin-2.2.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hugeballs/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.4.1/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]

http://www.slf4j.org/codes.html#multiple_bindings

Note The warning emitted by SLF4J is just that, a warning. Even when multiple bindings are present, SLF4J will pick one logging framework/implementation and bind with it. The way SLF4J picks a binding is determined by the JVM and for all practical purposes should be considered random. As of version 1.6.6, SLF4J will name the framework/implementation class it is actually bound to.

Embedded components such as libraries or frameworks should not declare a dependency on any SLF4J binding but only depend on slf4j-api. When a library declares a compile-time dependency on a SLF4J binding, it imposes that binding on the end-user, thus negating SLF4J's purpose. When you come across an embedded component declaring a compile-time dependency on any SLF4J binding, please take the time to contact the authors of said component/library and kindly ask them to mend their ways.

@ghost ghost mentioned this issue Dec 7, 2015
@TheSnoozer
Copy link
Collaborator

The reason why we have the SLF4J-StaticLoggerBinder in the jar is because Maven screwed up the class loading. See #198 and https://issues.apache.org/jira/browse/MNG-5787

What version of Maven you are using?
Could you provide an example how we could reproduce the Problem?

@g1franc
Copy link

g1franc commented Jan 13, 2016

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/tools/maven/repository/pl/project13/maven/git-commit-id-plugin/2.2.0/git-commit-id-plugin-2.2.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/tools/maven/repository/org/slf4j/slf4j-simple/1.7.12/slf4j-simple-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]

@g1franc
Copy link

g1franc commented Jan 13, 2016

Maven version is 2.2.1

@autayeu
Copy link
Contributor

autayeu commented Jan 13, 2016

#233 might solve this by removing SLF4J altogether.

@ktoso ktoso added this to the 2.2.1 milestone Mar 26, 2016
@ktoso
Copy link
Collaborator

ktoso commented Mar 26, 2016

This is solved by the linked PRs, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants