Skip to content

Remove only the JUL bridge handler installed by the logging system - #52825

Open
MycroCosmo wants to merge 1 commit into
spring-projects:4.0.xfrom
MycroCosmo:preserve-application-jul-bridges
Open

MycroCosmo wants to merge 1 commit into
spring-projects:4.0.xfrom
MycroCosmo:preserve-application-jul-bridges

Conversation

@MycroCosmo

@MycroCosmo MycroCosmo commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

After Boot installs a JUL bridge, an application can reconfigure the root logger and install a replacement. On cleanup, Logback uninstalls every SLF4J bridge on the current root logger, and Log4j2 closes and removes every Log4j bridge. Both remove the application's handler along with their own.

This change retains the logger and handler from installation so cleanup detaches only that instance. Log4j2 still closes its own handler to unregister its level propagation listener. Each regression test adds an application bridge alongside Boot's and checks that only the application's instance survives cleanup.

I reproduced the replacement case using a WAR adapted from #33697 on Boot 4.0.9, Tomcat 11.0.27 and JDK 17.0.14. Boot installed the initial bridge, and the application replaced it in @PostConstruct. The JUL message in @PreDestroy was lost on undeploy and again on server stop after redeploy. With the changed Logback class the callback logged exactly once on each occasion.

This follows up on the ownership check in #50779. The cleanup timing change in #52233 is complementary.

Gradle verification. On Windows with JDK 25, both new tests failed against the parent implementation and passed on this commit. Both format checks passed. Running the two entire logging test classes gave 16 failures before the change and 14 afterward (146 tests in each run, including the two new tests). The same 14 existing Log4j2 cases failed in both runs.

Keep the installed handler and its JUL root logger together so cleanup leaves handlers registered later by the application in place. Exercise this behavior with both Logback and Log4j2.

Signed-off-by: sunghwan kwon <sunghwan.ian.kwon@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. label Nov 18, 2026

This branch has not been deployed

No deployments
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 that has not yet been triaged. Contributions will not be accepted.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants