-
Notifications
You must be signed in to change notification settings - Fork 41k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register Logback OnErrorConsoleStatusListener when using custom Logback file #43931
Conversation
…ck file Prior to this commit, OnErrorConsoleStatusListener was not registered for a custom Logback configuration file. This commit registers OnErrorConsoleStatusListener when the Logback configuration is loaded from a custom Logback file that does not include any StatusListener. See spring-projectsgh-43822 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
Maybe Spring Boot should consistently register |
Update `LogbackLoggingSystem` so that the `OnErrorConsoleStatusListener` is also registered when loading a custom Logback configuration file. See gh-43931 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
Introduce a `SystemStatusListener` class to simplify Logback status listener registration for both debug and regular output. See gh-43931
Thanks very much @nosan, I've got with your After merging, I realized that the Please let me know if you foresee any issues with commit 8536950. |
Thank you, @philwebb. I reviewed your changes regarding If you try to run an application right now, you will see the following output:
This occurs because public void start() {
isStarted = true;
if (retrospectiveThresold > 0) {
retrospectivePrint(); //print all statuses
}
}
private void retrospectivePrint() {
if (context == null)
return;
long now = System.currentTimeMillis();
StatusManager sm = context.getStatusManager();
List<Status> statusList = sm.getCopyOfStatusList();
for (Status status : statusList) {
long timestampOfStatusMesage = status.getTimestamp();
if (isElapsedTimeLongerThanThreshold(now, timestampOfStatusMesage)) {
print(status);
}
}
}
Also, I noticed that I fixed both issues in the following branch: main...nosan:spring-boot:43822-3 |
Fix `SystemStatusListener` so that superfluous output is not printed when starting an application. This change ensures that the `SystemStatusListener` is not added twice, and that retrospective logging only occurs when `debug` is true. See gh-43931 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
Change `SystemStatusListener` to a `OnConsoleStatusListener` to ensure that it cannot be added twice from different threads. Also add a local `retrospectivePrint()` that is used for non-debug output that will print ERROR and WARN status, but not INFO. See gh-43931
Thanks @nosan. There's some pretty interesting stuff going on here. I didn't appreciate that I also went back a debugged the old version and discovered that the Hopefully c884529 takes care of those changes, but let me know if you find any more issues. Thanks again for all your work on this! |
Thank you, @philwebb I tested your changes again, and everything works perfectly! I’ve prepared a polished commit for your changes if you don't mind. main...nosan:spring-boot:43822-4 |
BTW, I think this issue #43822 should be closed as well. |
See gh-43931 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
* pr/43931: Polish SystemStatusListener Closes gh-43931
Nice! I've merged that one as well. |
Prior to this commit,
OnErrorConsoleStatusListener
was not registered for a custom Logback configuration file.This commit registers
OnErrorConsoleStatusListener
when the Logback configuration is loaded from a custom Logback file that does not include anyStatusListener
.See gh-43822
It has also been tested with a native image.
A different approach is to register
OnErrorConsoleStatusListener
right afterreportConfigurationErrorsIfNecessary
.main...nosan:spring-boot:43822-1