Skip to content

Restore default JUL root handler on Logback cleanup - #50969

Open
rsrizvi wants to merge 1 commit into
spring-projects:4.0.xfrom
rsrizvi:gh-50404-restore-jul-root-console-handler
Open

rsrizvi wants to merge 1 commit into
spring-projects:4.0.xfrom
rsrizvi:gh-50404-restore-jul-root-console-handler

Conversation

@rsrizvi

@rsrizvi rsrizvi commented Jul 17, 2026

Copy link
Copy Markdown

When the JUL-to-SLF4J bridge is installed, the default java.util.logging root ConsoleHandler is removed. When the logging system is cleaned up (for example when an ApplicationFailedEvent is published), the bridge is uninstalled but the ConsoleHandler was not restored, leaving the JUL root logger with no handlers. Anything subsequently logged through JUL, such as a startup failure reported via a JUL-backed commons-logging Log, was then silently discarded.

Restore the default ConsoleHandler when uninstalling the bridge so that JUL logging continues to work after cleanup.

See gh-50404

When the JUL-to-SLF4J bridge is installed, the default java.util.logging
root ConsoleHandler is removed. When the logging system is cleaned up
(for example when an ApplicationFailedEvent is published), the bridge is
uninstalled but the ConsoleHandler was not restored, leaving the JUL
root logger with no handlers. Anything subsequently logged through JUL,
such as a startup failure reported via a JUL-backed commons-logging Log,
was then silently discarded.

Restore the default ConsoleHandler when uninstalling the bridge so that
JUL logging continues to work after cleanup.

See spring-projectsgh-50404

Signed-off-by: Rameel Rizvi <rrizvi@alumni.cmu.edu>

@wilkinsona wilkinsona left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the proposal. I've left a comment for your consideration. Additionally, similar changes would have to be made to Log4J2LoggingSystem as it too manipulates the root handler.

// was installed. Without this, anything logged through JUL after cleanup
// (for example a startup failure reported via a JUL-backed commons-logging
// Log) would be silently discarded (see gh-50404).
restoreDefaultRootHandler();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're calling removeJdkLoggingBridgeHandler() which may remove the default root handler and then immediately restoring it. I suspect that the remove will be a no-op in this code path, but the structure of the proposed code is confusing as it appears that we're removing and then immediately restoring. It would be better if the no-op remove didn't happen at all in this codepath.

@wilkinsona wilkinsona self-assigned this Sep 11, 2026
@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants