Skip to content
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

Multiple SLF4j bindings in class path #2174

Closed
scholzj opened this issue Jul 23, 2024 · 0 comments · Fixed by #2175
Closed

Multiple SLF4j bindings in class path #2174

scholzj opened this issue Jul 23, 2024 · 0 comments · Fixed by #2175

Comments

@scholzj
Copy link

scholzj commented Jul 23, 2024

ZooKeeper 3.8 has the Logback logging library as a dependency. That now seems to be pulled into Cruise Control in 2.5.138 as well and leads to multiple different SLF4j binding being included in the classpath. This can cause problems with logging configuration since the actual binding used by SLF4J might randomly pick one of the bindings. It could be Log4j2 as desired:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cruise-control/libs/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cruise-control/libs/logback-classic-1.2.10.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.apache.logging.slf4j.Log4jLoggerFactory]

But it could also be Logback:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cruise-control/libs/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cruise-control/libs/log4j-slf4j-impl-2.17.2.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 [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

In this case the Log4j configuration will be ignored.

I guess ideally we want to exclude the Logback dependency from the ZooKeeper dependency?

robobario added a commit to robobario/cruise-control that referenced this issue Jul 23, 2024
A logback slf4j binding is being pulled in via zookeeper causing issues
at runtime because we have two slf4j bindings available. Slf4j chooses
one implementation and it can pick logback, which is unexpected.

Fixes linkedin#2174

Signed-off-by: Robert Young <[email protected]>
mborst pushed a commit to DataDog/cruise-control that referenced this issue Sep 19, 2024
Exclude logback from being depended on transitively (following established pattern for excluding log4j:log4j)

Why:
A logback slf4j binding is being pulled in via zookeeper causing issues at runtime because we have two slf4j bindings available. Slf4j chooses one implementation and it can pick logback, which is unexpected.

To reproduce on `main`:

```
gradle clean build -q -x test && ./kafka-cruise-control-start.sh config/cruisecontrol.properties 2>&1 | grep SLF4J
... gradle noises ...
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/robeyoun/development/upstream/cruise-control/cruise-control/build/dependant-libs/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/robeyoun/development/upstream/cruise-control/cruise-control/build/dependant-libs/logback-classic-1.2.10.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.apache.logging.slf4j.Log4jLoggerFactory]
```

This PR resolves linkedin#2174
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

Successfully merging a pull request may close this issue.

1 participant