diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-09-24 18:19:50 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-09-24 18:19:50 +0200 |
commit | 85c037c87a728edbefc0fd417d6cb89cab246e44 (patch) | |
tree | e3522ce24ff20fe3d3d0647bee363dd74e28fdf1 /server | |
parent | 410c98978ca7ee3c667dcbcffe4d3ec085c6e517 (diff) | |
download | sonarqube-85c037c87a728edbefc0fd417d6cb89cab246e44.tar.gz sonarqube-85c037c87a728edbefc0fd417d6cb89cab246e44.zip |
SONAR-5621 Merge server log files into a single one
Diffstat (limited to 'server')
9 files changed, 10 insertions, 18 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java index 77a4b607d0d..3cedc1c9c84 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java @@ -49,7 +49,7 @@ public class JavaProcessLauncher { commands.prepare(); ProcessBuilder processBuilder = create(command); - LoggerFactory.getLogger(getClass()).info("Launch {}: {}", + LoggerFactory.getLogger(getClass()).info("Launch process[{}]: {}", command.getKey(), StringUtils.join(processBuilder.command(), " ")); process = processBuilder.start(); StreamGobbler inputGobbler = new StreamGobbler(process.getInputStream(), command.getKey()); diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java index 672fdf6cb6c..31eae8e9ba3 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java @@ -90,7 +90,6 @@ class ProcessRef { ProcessUtils.sendKillSignal(process); // signal is sent, waiting for shutdown hooks to be executed (or not... it depends on OS) process.waitFor(); - LoggerFactory.getLogger(getClass()).info(String.format("%s is stopped", this)); } catch (InterruptedException ignored) { // can't wait for the termination of process. Let's assume it's down. diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java index d5f54e33248..2115884b189 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java @@ -38,7 +38,7 @@ class StreamGobbler extends Thread { private final Logger logger; StreamGobbler(InputStream is, String processKey) { - this(is, processKey, LoggerFactory.getLogger(processKey)); + this(is, processKey, LoggerFactory.getLogger("gobbler")); } StreamGobbler(InputStream is, String processKey, Logger logger) { diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/TerminatorThread.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/TerminatorThread.java index b40291f164a..a774868f75a 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/TerminatorThread.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/TerminatorThread.java @@ -68,6 +68,7 @@ class TerminatorThread extends Thread { LoggerFactory.getLogger(getClass()).info(String.format("%s failed to stop in a timely fashion. Killing it.", ref)); } ref.stop(); + LoggerFactory.getLogger(getClass()).info(String.format("%s is stopped", ref)); } } } 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 18893090bf3..2fb7baa865e 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 @@ -50,8 +50,8 @@ public class ProcessLogging { Logger consoleLogger = (Logger) LoggerFactory.getLogger("console"); Appender<ILoggingEvent> consoleAppender = consoleLogger.getAppender("CONSOLE"); - Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - rootLogger.addAppender(consoleAppender); + Logger gobblerLogger = (Logger) LoggerFactory.getLogger("gobbler"); + gobblerLogger.addAppender(consoleAppender); } /** diff --git a/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java b/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java index cb039b55162..d63abe3b2b5 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java +++ b/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java @@ -249,7 +249,7 @@ public class SearchServer implements Monitored { @Override public synchronized void stop() { - if (!node.isClosed()) { + if (node != null && !node.isClosed()) { node.close(); } } 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 d10553b643b..3c24d95cdc0 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 @@ -12,7 +12,7 @@ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern> - %d{yyyy.MM.dd HH:mm:ss} %-5level [%logger{20}] %X %msg%n + %d{yyyy.MM.dd HH:mm:ss} %-5level sea[%logger{20}] %X %msg%n </pattern> </encoder> </appender> diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/Logging.java b/server/sonar-server/src/main/java/org/sonar/server/app/Logging.java index fefc1444a3b..e5d8c52b225 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/app/Logging.java +++ b/server/sonar-server/src/main/java/org/sonar/server/app/Logging.java @@ -37,20 +37,15 @@ import java.util.logging.LogManager; class Logging { - private static final String CONFIG_LOG_CONSOLE = "sonar.log.console"; - private static final String LOG_COMMON_PREFIX = "%d{yyyy.MM.dd HH:mm:ss} %-5level "; private static final String LOG_COMMON_SUFFIX = "%msg%n"; - private static final String LOG_LOGFILE_SPECIFIC_PART = "[%logger{20}] %X "; + private static final String LOG_LOGFILE_SPECIFIC_PART = "web[%logger{20}] %X "; private static final String LOG_FULL_SPECIFIC_PART = "%thread "; private static final String LOGFILE_STANDARD_LOGGING_FORMAT = LOG_COMMON_PREFIX + LOG_LOGFILE_SPECIFIC_PART + LOG_COMMON_SUFFIX; private static final String LOGFILE_FULL_LOGGING_FORMAT = LOG_COMMON_PREFIX + LOG_FULL_SPECIFIC_PART + LOG_LOGFILE_SPECIFIC_PART + LOG_COMMON_SUFFIX; - private static final String CONSOLE_STANDARD_LOGGING_FORMAT = LOG_COMMON_PREFIX + LOG_COMMON_SUFFIX; - private static final String CONSOLE_FULL_LOGGING_FORMAT = LOG_COMMON_PREFIX + LOG_FULL_SPECIFIC_PART + LOG_COMMON_SUFFIX; - static final String ACCESS_RELATIVE_PATH = "WEB-INF/config/logback-access.xml"; static final String PROPERTY_ENABLE_ACCESS_LOGS = "sonar.web.accessLogs.enable"; @@ -71,12 +66,9 @@ class Logging { private static void configureLogback(Props props) { String configProfilingLevel = props.value(Profiling.CONFIG_PROFILING_LEVEL, "NONE"); Profiling.Level profilingLevel = Profiling.Level.fromConfigString(configProfilingLevel); - String consoleEnabled = props.value(CONFIG_LOG_CONSOLE, "false"); Map<String, String> variables = ImmutableMap.of( "sonar.path.logs", props.nonNullValue("sonar.path.logs"), - "LOGFILE_LOGGING_FORMAT", profilingLevel == Profiling.Level.FULL ? LOGFILE_FULL_LOGGING_FORMAT : LOGFILE_STANDARD_LOGGING_FORMAT, - "CONSOLE_LOGGING_FORMAT", profilingLevel == Profiling.Level.FULL ? CONSOLE_FULL_LOGGING_FORMAT : CONSOLE_STANDARD_LOGGING_FORMAT, - "CONSOLE_ENABLED", consoleEnabled); + "LOGGING_FORMAT", profilingLevel == Profiling.Level.FULL ? LOGFILE_FULL_LOGGING_FORMAT : LOGFILE_STANDARD_LOGGING_FORMAT); Logback.configure("/org/sonar/server/platform/logback.xml", variables); } 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 84ce76baece..9dc53c89a8b 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 @@ -12,7 +12,7 @@ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern> - ${LOGFILE_LOGGING_FORMAT} + ${LOGGING_FORMAT} </pattern> </encoder> </appender> |