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

shardingsphere-logging-core should not set the scope of logback-classic to compile #32377

Closed
linghengqian opened this issue Aug 3, 2024 · 3 comments · Fixed by #32389 or #32418
Closed

Comments

@linghengqian
Copy link
Member

linghengqian commented Aug 3, 2024

Feature Request

For English only, other languages will not be accepted.

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot make decision by current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Is your feature request related to a problem?

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/linghengqian/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.18.0/log4j-slf4j-impl-2.18.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/linghengqian/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/linghengqian/.m2/repository/ch/qos/logback/logback-classic/1.2.13/logback-classic-1.2.13.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]
  • These JARs come from hive-service, but there are also issues with the processing on the shardingsphere side.
commons-logging:commons-logging:1.2
org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1
org.jboss.logging:jboss-logging:3.1.3.GA
org.apache.logging.log4j:log4j-1.2-api:2.18.0
org.apache.logging.log4j:log4j-api:2.18.0
org.apache.logging.log4j:log4j-core:2.18.0
org.apache.logging.log4j:log4j-slf4j-impl:2.18.0
org.apache.logging.log4j:log4j-web:2.18.0
log4j:log4j:1.2.17
org.slf4j:slf4j-log4j12:1.7.25

ShardingSphere-JDBC is a SDK.

Describe the feature you would like.

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.

  • I think the scope of ch.qos.logback:logback-classic should be set to provided to stop the Slf4j implementation from being passed on. Downstream applications should always manually import their favorite Slf4j implementation.
@RaigorJiang
Copy link
Contributor

Yes, the design of logging rule is flawed. I think it can be disabled (temporarily removed from modules) before it is actually available.

@linghengqian
Copy link
Member Author

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-nop</artifactId>
    <version>1.7.36</version>
</dependency>

@linghengqian
Copy link
Member Author

linghengqian commented Aug 6, 2024

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-jdbc</artifactId>
    <version>5.5.1-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.2.13</version>
</dependency>
  • In fact, we need to change all the calls to Logback Java API in shardingsphere-logging-core to calls to Slf4j Java API.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment