-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Enhancement] Bridge java.util.logging to slf4j to fix log leakage #67129
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
[Enhancement] Bridge java.util.logging to slf4j to fix log leakage #67129
Conversation
1e5218a to
28354ee
Compare
28354ee to
9613e5f
Compare
9613e5f to
111649c
Compare
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.
Pull request overview
This PR fixes a log leakage issue where third-party libraries using java.util.logging (JUL) were printing logs directly to stdout/fe.out instead of the standard log files. The solution implements the standard JUL-to-SLF4J bridging mechanism to route all JUL logs through Log4j2.
Key changes:
- Added
jul-to-slf4jdependency to enable JUL bridge functionality - Initialized the SLF4J bridge in the logging configuration to redirect JUL logs
- Added a unit test to verify JUL logs are correctly captured by Log4j2
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| fe/pom.xml | Added jul-to-slf4j dependency version 1.7.30 to parent POM dependency management |
| fe/fe-core/pom.xml | Added jul-to-slf4j dependency reference in fe-core module |
| fe/fe-core/src/main/java/com/starrocks/common/Log4jConfig.java | Added JUL bridge initialization by calling LogManager.reset() and SLF4JBridgeHandler.install() in reconfig() |
| fe/fe-core/src/test/java/com/starrocks/common/Log4jConfigTest.java | Added unit test to verify JUL logs are captured and routed through Log4j2 |
9fe3940 to
741ed08
Compare
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.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
fe/fe-core/src/test/java/com/starrocks/common/Log4jConfigTest.java
Outdated
Show resolved
Hide resolved
3916826 to
3ba311c
Compare
|
@kevincai I have pushed the final implementation addressing all feedback. 1. Regarding Logic in
|
|
@Mergifyio rebase |
✅ Branch has been successfully rebased |
3ba311c to
b65199c
Compare
|
@kevincai Thanks for the approval and the rebase! I noticed the Since this PR touches the Java logging initialization, could this be a side effect causing the JVM/BE to crash, or does this look like a known flaky CI issue to you? Please let me know if you want me to revert anything. |
It's an CI env issue, I will take care of it. |
|
@cursor review |
1cc51e1 to
2c22473
Compare
|
@kevincai @alvin-celerdata The latest CI (FE UT) run failed on The error message Could you please re-trigger the CI to clear this flake? |
|
@cursor review |
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.
✅ Bugbot reviewed your changes and found no bugs!
|
@Mergifyio rebase |
Fixes StarRocks#31777. This PR bridges java.util.logging logs to slf4j so they are handled by log4j2 configuration instead of being leaked to stdout. This is necessary for libraries like jprotobuf-rpc-socket which use java.util.logging. Changes: 1. Add jul-to-slf4j dependency. 2. Initialize SLF4JBridgeHandler in Log4jConfig with dynamic level alignment. 3. Replace LogManager.reset() with removeHandlersForRootLogger() for safety. 4. Add unit test to verify the bridge. Signed-off-by: arvindksi274-ksolves <[email protected]>
Fixes StarRocks#31777. This PR bridges java.util.logging logs to slf4j so they are handled by log4j2 configuration instead of being leaked to stdout. This is necessary for libraries like jprotobuf-rpc-socket which use java.util.logging. Changes: 1. Add jul-to-slf4j dependency. 2. Initialize SLF4JBridgeHandler in Log4jConfig with dynamic level alignment. 3. Replace LogManager.reset() with removeHandlersForRootLogger() for safety. 4. Add validation logic to default to INFO for unsupported levels. 5. Add unit test to verify the bridge, level mapping, and fallback logic. Signed-off-by: arvindksi274-ksolves <[email protected]>
✅ Branch has been successfully rebased |
2c22473 to
d1aaf5e
Compare
|
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 15 / 16 (93.75%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
|
@cursor review |
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.
✅ Bugbot reviewed your changes and found no bugs!
|
@Mergifyio backport branch-4.0 |
✅ Backports have been createdDetails
|
…67129) Signed-off-by: arvindksi274-ksolves <[email protected]> (cherry picked from commit 5b244bd)
…ackport #67129) (#67279) Signed-off-by: arvindksi274-ksolves <[email protected]> Co-authored-by: Arvind Kandpal <[email protected]>



Why I'm doing:
Currently, third-party libraries that rely on
java.util.logging(JUL), such asjprotobuf-rpc-socket, print logs directly tostdout(which redirects tofe.out) instead of the standard log files. This happens because the JUL-to-SLF4J bridge is not properly initialized, causing log leakage and making debugging difficult as these logs are missing fromfe.log.What I'm doing:
I have implemented the standard bridging mechanism to route
java.util.loggingcalls to SLF4J (Log4j2).Changes:
org.slf4j:jul-to-slf4jdependency infe/pom.xmlandfe/fe-core/pom.xml.LogManager.getLogManager().reset()andSLF4JBridgeHandler.install()inLog4jConfig.javato redirect logs.testJulToSlf4jBridgeinLog4jConfigTest.javato verify that JUL logs are correctly captured by Log4j2.This PR supersedes and fixes the unmerged PR #56156.
Fixes #31777
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
Note
Ensures logs from JUL-based libraries flow into the existing SLF4J/Log4j2 pipeline and match configured log levels.
org.slf4j:jul-to-slf4jdependency infe/pom.xmlandfe/fe-core/pom.xmlLog4jConfig.reconfig(), installSLF4JBridgeHandler, remove root JUL handlers, and set JUL root level based onsys_log_level(DEBUG→FINE,INFO→INFO,WARN→WARNING,ERROR|FATAL→SEVERE)Log4jConfigTest:testJulToSlf4jBridge(JUL logs captured by Log4j2) andtestJulLevelMapping(JUL level mapping and invalid level handling)Written by Cursor Bugbot for commit d1aaf5e. This will update automatically on new commits. Configure here.