question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace slf4j-simple Dependency w/ slf4j-api

See original GitHub issue

Is your feature request related to a problem? Please describe. Redisson in https://github.com/redisson/redisson/blob/master/redisson-all/pom.xml#L96 creates a hard dependency on an SLF4J binding, which if you already have a binding in place in your application, causes logs like:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/tomcat/apache-tomcat-7.0.90/lib/redisson-all-3.13.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/tomcat/apache-tomcat-7.0.90/webapps/some-webapp/WEB-INF/lib/slf4j-nop-1.6.4.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.helpers.NOPLoggerFactory]

Note the link and warning from SLF4J: http://www.slf4j.org/codes.html#multiple_bindings. This is a random behavior and could be catastrophic depending on your intended logging config versus what Redisson attempts to do. Also note this paragraph:

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.

Describe the solution you’d like

Remove the dependency on slf4j-simple and replace it with slf4j-api like is recommended by SLF4J. This is noted in the SLF4J link above and is concisely:

Embedded components such as libraries or frameworks should not declare a dependency on any SLF4J binding but only depend on slf4j-api.

Describe alternatives you’ve considered

We have considered rebuilding the Redisson jars to remove this dependency, but it should not be there to begin with.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mrnikocommented, Aug 13, 2020

Fixed

1reaction
KenZZ107commented, Aug 10, 2020

I don’t know if that would be acceptable or not to make those users have to configure their own logging setup. What about splitting the redisson-all setup into two things:

  • redisson-common - the common jar that is capable of being used with other things, like Tomcat, which brings in slf4j-api.
  • redisson-standalone - the standalone functionality that then brings in slf4j-simple.

Looking at the other framework integrations in https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks, it looks like Tomcat is the only one that actually requires the redisson-all jar to be involved. I am not entirely sure why that is, but maybe an adjustment there would be suitable putting more into redisson-tomcat?

Maybe that‘s because redisson is a dependency of some app which could be handled by build tools like maven or gradle in other integration situations, while with tomcat you have to put it manually. In fact, you can place redisson-tomcat-X-*.jar and all jars it depends on(including transitived ones) into tomcat/lib.

But yet, I vote for an extra redisson-tomcat-full.jar without slf4j-simple. :p

Read more comments on GitHub >

github_iconTop Results From Across the Web

SLF4J Manual
The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks, such as java.util.logging, logback and ......
Read more >
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"
I followed that and added slf4j-simple-1.6.1.jar to my ... All configuration was fine, but slf4j-log4j12 dependency which I copied from ...
Read more >
SLF4J Binding Using Log4j – Project Dependencies
GroupId, ArtifactId, Version, Type, Licenses, Optional. org.apache.logging.log4j, log4j-api, 2.19.0, jar, Apache License, Version 2.0, No.
Read more >
Bundles org.slf4j.api and org.slf4j.jcl breaks commons.logging
spi;version=1.5.11 Reproducible: Always Steps to Reproduce: 1. unzip eclipse 3.6.rc1 2. install Mylyn from the helios miletsones repository 3.
Read more >
SLF4J Logback Tutorial - Mkyong.com
Viewed: 93,006 (+542 pv/w). Tags:logback ... A simple SLF4J with Logback example. ... pull in logback-core and slf4j-api --> <dependency> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found