Repository navigation
Remove only the JUL bridge handler installed by the logging system - #52825
Open
MycroCosmo wants to merge 1 commit into
Open
MycroCosmo wants to merge 1 commit into
MycroCosmo wants to merge 1 commit into
Conversation
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>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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@PreDestroywas 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.