-
Notifications
You must be signed in to change notification settings - Fork 23
Updates for logging under Java 21 #317
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
base: master
Are you sure you want to change the base?
Conversation
return LoggerFactory.getLogger(module.getClass()); | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What error were you getting before this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J(W): Ignoring binding found at [jar:file:/E:/COMMON/osh-node/build/distributions/osh-node-2.0-beta2/lib/logback-classic-1.2.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J(W): Ignoring binding found at [jar:file:lib/logback-classic-1.2.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J(W): See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
I was seeing this issue, unfortunately, this morning I cannot reproduce. However, updating the build.gradle file noted with this PR to use
api 'ch.qos.logback:logback-classic:1.5.13'
api 'com.fasterxml.woodstox:woodstox-core:6.4.0'
Does eliminate CVEs in builds, and I was running yesterday with these updates.
I think I can just sit on this and see if I can reproduce the issue,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hold on I just reproduced the build break...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Task :osh-core:sensorhub-core:compileJava FAILED
E:\CUBIC\osh-node\include\osh-core\sensorhub-core\src\main\java\org\sensorhub\utils\ModuleUtils.java:31: error: package org.slf4j.impl does not exist
import org.slf4j.impl.StaticLoggerBinder;
- on master branch, after wiping all builds
- using OpenLogic OpenJDK 21.0.8
- building on Windows 11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using CoPilot to assess the issue
You're encountering this error because SLF4J version 2.x no longer uses the StaticLoggerBinder class. Instead, it relies on the Java ServiceLoader mechanism to discover logging implementations at runtime.
🔍 What's Happening
The org.slf4j.impl.StaticLoggerBinder class was part of SLF4J 1.x.
In SLF4J 2.x, this static binding mechanism was removed.
If you're using SLF4J 2.x but trying to import StaticLoggerBinder, you'll get the "package does not exist" error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am able to reproduce when building SensorHub Test, but it is odd because it is intermittently breaking while other times exhibiting the following "warning"
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J(W): Ignoring binding found at [jar:file:/C:/Users/Nicolas%20Garay/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.13/e9f3458e7354fe4917081237c01fa4999f4e1b86/logback-classic-1.2.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J(W): See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
Under Java 21 the StaticLogger is no longer available so the dependencies needed updating and the logic to create loggers had to change to resolve a registered logger implementation for Log4J other than default NOP logger (no operation)