From: Simon Brandhof Date: Wed, 24 Sep 2014 12:35:43 +0000 (+0200) Subject: SONAR-5621 merge log files X-Git-Tag: 4.5-RC3~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=410c98978ca7ee3c667dcbcffe4d3ec085c6e517;p=sonarqube.git SONAR-5621 merge log files --- diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessLogging.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessLogging.java index c0909a93fb5..18893090bf3 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessLogging.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessLogging.java @@ -19,8 +19,11 @@ */ package org.sonar.process; +import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.joran.JoranConfigurator; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.Appender; import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.util.StatusPrinter; import org.slf4j.LoggerFactory; @@ -43,6 +46,14 @@ public class ProcessLogging { StatusPrinter.printInCaseOfErrorsOrWarnings(context); } + public void addConsoleAppender() { + Logger consoleLogger = (Logger) LoggerFactory.getLogger("console"); + Appender consoleAppender = consoleLogger.getAppender("CONSOLE"); + + Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + rootLogger.addAppender(consoleAppender); + } + /** * Extracted only for unit testing */ diff --git a/server/sonar-search/src/main/resources/org/sonar/search/logback.xml b/server/sonar-search/src/main/resources/org/sonar/search/logback.xml index 648ece82e28..d10553b643b 100644 --- a/server/sonar-search/src/main/resources/org/sonar/search/logback.xml +++ b/server/sonar-search/src/main/resources/org/sonar/search/logback.xml @@ -9,18 +9,8 @@ - - ${sonar.path.logs}/search.log - - - - - - - - + - %d{yyyy.MM.dd HH:mm:ss} %-5level [%logger{20}] %X %msg%n @@ -29,7 +19,7 @@ - + diff --git a/server/sonar-server/src/main/resources/org/sonar/server/platform/logback.xml b/server/sonar-server/src/main/resources/org/sonar/server/platform/logback.xml index 4607ddb23bf..84ce76baece 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/platform/logback.xml +++ b/server/sonar-server/src/main/resources/org/sonar/server/platform/logback.xml @@ -9,40 +9,14 @@ - - ${sonar.path.logs}/sonar.log - - - - - - - - - - - - ${LOGFILE_LOGGING_FORMAT} - - - - - - WARN - - ${CONSOLE_LOGGING_FORMAT} + ${LOGFILE_LOGGING_FORMAT} - - - - - @@ -93,7 +67,7 @@ - + diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java index bba2dd73069..502cf561394 100644 --- a/sonar-application/src/main/java/org/sonar/application/App.java +++ b/sonar-application/src/main/java/org/sonar/application/App.java @@ -109,7 +109,11 @@ public class App implements Stoppable { CommandLineParser cli = new CommandLineParser(); Properties rawProperties = cli.parseArguments(args); Props props = new PropsBuilder(rawProperties, new JdbcSettings()).build(); - new ProcessLogging().configure(props, "/org/sonar/application/logback.xml"); + ProcessLogging logging = new ProcessLogging(); + logging.configure(props, "/org/sonar/application/logback.xml"); + if (props.valueAsBoolean("sonar.log.console", false)) { + logging.addConsoleAppender(); + } App app = new App(); app.start(props); diff --git a/sonar-application/src/main/resources/org/sonar/application/logback.xml b/sonar-application/src/main/resources/org/sonar/application/logback.xml index 246afdf89f3..e34156819f0 100644 --- a/sonar-application/src/main/resources/org/sonar/application/logback.xml +++ b/sonar-application/src/main/resources/org/sonar/application/logback.xml @@ -3,17 +3,36 @@ + + ${sonar.path.logs}/sonar.log + + + + + + + + + + %3.3logger %msg%n + + + - %d{yyyy.MM.dd HH:mm:ss} %-5level %msg%n + app %d{yyyy.MM.dd HH:mm:ss} %-5level [%logger{20}] %msg%n + + + + - +