Fix SystemStatusListener to prevent superfluous output

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>
This commit is contained in:
Dmytro Nosan
2025-01-28 12:41:16 +02:00
committed by Phillip Webb
parent fc01b011d5
commit 6ba8e9b089
3 changed files with 68 additions and 6 deletions

View File

@@ -36,11 +36,12 @@ import static org.assertj.core.api.Assertions.assertThat;
class SampleStructuredLoggingApplicationTests {
@AfterEach
void reset() {
void reset(CapturedOutput output) {
LoggingSystem.get(getClass().getClassLoader()).cleanUp();
for (LoggingSystemProperty property : LoggingSystemProperty.values()) {
System.getProperties().remove(property.getEnvironmentVariableName());
}
assertThat(output).doesNotContain("-INFO in ch.qos.logback.classic.LoggerContext");
}
@Test