Skip to content

Avoid removing application-managed JUL bridge handler#50779

Open
dhruv-15-03 wants to merge 1 commit into
spring-projects:mainfrom
dhruv-15-03:fix-jul-bridge-uninstall-asymmetry
Open

Avoid removing application-managed JUL bridge handler#50779
dhruv-15-03 wants to merge 1 commit into
spring-projects:mainfrom
dhruv-15-03:fix-jul-bridge-uninstall-asymmetry

Conversation

@dhruv-15-03

Copy link
Copy Markdown

This addresses the install/uninstall asymmetry described in #33697.

LogbackLoggingSystem and Log4J2LoggingSystem install a JUL bridge handler (SLF4JBridgeHandler / Log4jBridgeHandler) only when the application is not already managing java.util.logging itself (i.e. when the JUL root logger is using at most a single ConsoleHandler). However, cleanUp() removed the bridge handler whenever the bridge class was merely present on the classpath.

As a result, when an application installs and manages its own JUL bridge handler, Spring Boot would still uninstall it during context shutdown — tearing down a handler it never installed.

This change tracks whether the bridge handler was installed by Spring Boot and only removes it during cleanup when that is the case, making install and uninstall symmetric.

A test is added to each logging system verifying that an application-installed bridge handler is left in place after cleanUp(). Both tests fail without the corresponding production change.

Note: this PR is scoped to the install/uninstall asymmetry. The separate question of when the bridge handler is removed during the context lifecycle (also discussed in the issue) is intentionally left out of scope.

`LogbackLoggingSystem` and `Log4J2LoggingSystem` install a JUL bridge
handler only when the application is not already managing `java.util.logging`.
However, `cleanUp()` removed the bridge handler whenever the bridge class
was present on the classpath, so Spring Boot uninstalled a bridge handler
that an application had installed and managed itself.

Track whether the bridge handler was installed by Spring Boot and only
remove it during cleanup when that is the case.

See spring-projectsgh-33697

Signed-off-by: dhruv-15-03 <dhruvrastogi2004@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 17:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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