diff options
author | Jacek Poreda <jacek.poreda@sonarsource.com> | 2024-01-04 13:16:35 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-01-04 20:02:47 +0000 |
commit | 8fd8c030e7dda6eb03c83eb4e59474f5e2d4e401 (patch) | |
tree | 49b3697a2c62686eb6d815be0b35c3d5812a9a91 | |
parent | d111595d5a4e508d5f4108474825c22ae6424b99 (diff) | |
download | sonarqube-8fd8c030e7dda6eb03c83eb4e59474f5e2d4e401.tar.gz sonarqube-8fd8c030e7dda6eb03c83eb4e59474f5e2d4e401.zip |
SONAR-21227 Expose deprecation.log to console
2 files changed, 12 insertions, 0 deletions
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/app/WebServerProcessLogging.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/app/WebServerProcessLogging.java index b3bfdf3a06e..6a8536b9b95 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/app/WebServerProcessLogging.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/app/WebServerProcessLogging.java @@ -23,6 +23,7 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.ConsoleAppender; import ch.qos.logback.core.FileAppender; import ch.qos.logback.core.encoder.Encoder; import org.sonar.process.ProcessId; @@ -80,10 +81,12 @@ public class WebServerProcessLogging extends ServerProcessLogging { : helper.createPatternLayoutEncoder(context, buildDepractedLogPatrern(config)); FileAppender<ILoggingEvent> appender = helper.newFileAppender(context, props, DEPRECATION_LOG_FILE_PREFIX, encoder); + ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(context, "CONSOLE", encoder); Logger deprecated = context.getLogger(DEPRECATION_LOGGER_NAME); deprecated.setAdditive(false); deprecated.addAppender(appender); + deprecated.addAppender(consoleAppender); } private static String buildDepractedLogPatrern(RootLoggerConfig config) { diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java index 35d9ee15e17..d09fbad5d47 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/app/WebServerProcessLoggingTest.java @@ -558,6 +558,15 @@ public class WebServerProcessLoggingTest { assertThat(fileAppender.getEncoder()).isInstanceOf(LayoutWrappingEncoder.class); } + @Test + public void configure_shouldConfigureDeprecatedLoggerWithConsoleAppender() { + LoggerContext ctx = underTest.configure(props); + + Logger root = ctx.getLogger("SONAR_DEPRECATION"); + Appender<ILoggingEvent> appender = root.getAppender("CONSOLE"); + assertThat(appender).isNotNull(); + } + private void verifyRootLogLevel(LoggerContext ctx, Level expected) { Logger rootLogger = ctx.getLogger(ROOT_LOGGER_NAME); assertThat(rootLogger.getLevel()).isEqualTo(expected); |