Failure to log with SLF4J
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 51
Description
### Describe the bug
SLF4J logging does not work.
### Expected Behavior
I expect no SLF4J warnings and working logging.
### Current Behavior
SLF4J logging fails to initialize with this output:
```
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
```
### Reproduction Steps
The problem can easily be reproduced by triggering the slf4j initialization in jshell with the AWS SDK bundle jar and an SLF4j impl on the classpath:
```
$ CLASSPATH=~/.m2/repository/software/amazon/awssdk/bundle/2.26.5/bundle-2.26.5.jar:~/.m2/repository/org/slf4j/slf4j-simple/2.0.7/slf4j-simple-2.0.7.jar jshell
| Welcome to JShell -- Version 21.0.3
| For an introduction type: /help intro
jshell> software.amazon.awssdk.thirdparty.org.slf4j.impl.StaticLoggerBinder.getSingleton()
| Exception java.lang.NoClassDefFoundError: software.amazon.awssdk.thirdparty.org.slf4j.impl.StaticLoggerBinder
| at StaticLoggerBinder.getSingleton (StaticLoggerBinder.java:72)
| at (#1:1)
jshell>
```
Note that the NoClassDefFoundError is thrown by the StaticLoggerBinder (from the bundle-logging-bridge module) because it tries to load "org.slf4j.impl.StaticLoggerBinder", but that was shaded to "software.amazon.awssdk.thirdparty.org.slf4j.impl.StaticLoggerBinder"? Or maybe the intention is to load the actual org.slf4j.impl.StaticLoggerBinder from slf4j, but that doesn't seem to work either (cfr the slf4j-simpler jar on the classpath).
### Possible Solution
not sure.
### Additional Information/Context
_No response_
### AWS Java SDK version used
2.26.5
### JDK version used
21.0.3
### Operating System and version
Fedora 40
Contributor guide
Research direction
Reproduce the failure in jshell using the AWS SDK bundle jar, slf4j-simple, and JDK 21. Start with the bundle-logging-bridge module and its StaticLoggerBinder entry point, then trace the shaded class name shown in the NoClassDefFoundError. Done means SLF4J initializes without warnings and logging works with the documented classpath.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100