Skip to content

Restore default JUL root handler on Logback cleanup [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] - #51138

Closed
waterWang wants to merge 1 commit into
spring-projects:mainfrom
waterWang:restore-jul-handler-after-cleanup
Closed

Restore default JUL root handler on Logback cleanup [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]#51138
waterWang wants to merge 1 commit into
spring-projects:mainfrom
waterWang:restore-jul-handler-after-cleanup

Conversation

@waterWang

Copy link
Copy Markdown

Motivation

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.

Fixes #50969. See also #50404.

Modification

  • Add a defaultRootHandler field to save the ConsoleHandler reference before it is removed.
  • In removeDefaultRootHandler(), save the ConsoleHandler before removing it from the root logger.
  • In cleanUp(), after uninstalling the bridge, call restoreDefaultRootHandler() to add the saved ConsoleHandler back to the root logger.

Result

After the logging system is cleaned up, the JUL root logger still has its ConsoleHandler, so JUL logging continues to work.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 28, 2026
@snicoll

snicoll commented Jul 28, 2026

Copy link
Copy Markdown
Member

Please do not open a PR when one already exists

@snicoll snicoll closed this Jul 28, 2026
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants