import org.sonar.process.Props;
import static java.lang.String.format;
-import static java.util.Objects.requireNonNull;
import static org.slf4j.Logger.ROOT_LOGGER_NAME;
/**
return propagator;
}
- public static final class RootLoggerConfig {
- private final ProcessId processId;
- private final String threadIdFieldPattern;
-
- private RootLoggerConfig(Builder builder) {
- this.processId = requireNonNull(builder.processId);
- this.threadIdFieldPattern = builder.threadIdFieldPattern;
- }
-
- public static Builder newRootLoggerConfigBuilder() {
- return new Builder();
- }
-
- ProcessId getProcessId() {
- return processId;
- }
-
- String getThreadIdFieldPattern() {
- return threadIdFieldPattern;
- }
-
- public static final class Builder {
- @CheckForNull
- private ProcessId processId;
- private String threadIdFieldPattern = "";
-
- private Builder() {
- // prevents instantiation outside RootLoggerConfig, use static factory method
- }
-
- public Builder setProcessId(ProcessId processId) {
- this.processId = processId;
- return this;
- }
-
- public Builder setThreadIdFieldPattern(String threadIdFieldPattern) {
- this.threadIdFieldPattern = requireNonNull(threadIdFieldPattern, "threadIdFieldPattern can't be null");
- return this;
- }
-
- public RootLoggerConfig build() {
- return new RootLoggerConfig(this);
- }
- }
- }
-
- public String buildLogPattern(LogbackHelper.RootLoggerConfig config) {
+ public String buildLogPattern(RootLoggerConfig config) {
return LOG_FORMAT
.replace(PROCESS_NAME_PLACEHOLDER, config.getProcessId().getKey())
.replace(THREAD_ID_PLACEHOLDER, config.getThreadIdFieldPattern());
return fileAppender;
}
- public FileAppender<ILoggingEvent> newFileAppender(LoggerContext ctx, Props props, LogbackHelper.RootLoggerConfig config, String logPattern) {
+ public FileAppender<ILoggingEvent> newFileAppender(LoggerContext ctx, Props props, RootLoggerConfig config, String logPattern) {
RollingPolicy rollingPolicy = createRollingPolicy(ctx, props, config.getProcessId().getLogFilenamePrefix());
FileAppender<ILoggingEvent> fileAppender = rollingPolicy.createAppender("file_" + config.getProcessId().getLogFilenamePrefix());
fileAppender.setContext(ctx);
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.process.logging;
+
+import javax.annotation.CheckForNull;
+import org.sonar.process.ProcessId;
+
+import static java.util.Objects.requireNonNull;
+
+public final class RootLoggerConfig {
+ private final ProcessId processId;
+ private final String threadIdFieldPattern;
+
+ private RootLoggerConfig(Builder builder) {
+ this.processId = requireNonNull(builder.processId);
+ this.threadIdFieldPattern = builder.threadIdFieldPattern;
+ }
+
+ public static Builder newRootLoggerConfigBuilder() {
+ return new Builder();
+ }
+
+ ProcessId getProcessId() {
+ return processId;
+ }
+
+ String getThreadIdFieldPattern() {
+ return threadIdFieldPattern;
+ }
+
+ public static final class Builder {
+ @CheckForNull
+ private ProcessId processId;
+ private String threadIdFieldPattern = "";
+
+ private Builder() {
+ // prevents instantiation outside RootLoggerConfig, use static factory method
+ }
+
+ public Builder setProcessId(ProcessId processId) {
+ this.processId = processId;
+ return this;
+ }
+
+ public Builder setThreadIdFieldPattern(String threadIdFieldPattern) {
+ this.threadIdFieldPattern = requireNonNull(threadIdFieldPattern, "threadIdFieldPattern can't be null");
+ return this;
+ }
+
+ public RootLoggerConfig build() {
+ return new RootLoggerConfig(this);
+ }
+ }
+}
import org.sonar.process.logging.LogbackHelper;
import org.sonar.process.ProcessId;
import org.sonar.process.Props;
+import org.sonar.process.logging.RootLoggerConfig;
-import static org.sonar.process.logging.LogbackHelper.RootLoggerConfig.newRootLoggerConfigBuilder;
+import static org.sonar.process.logging.RootLoggerConfig.newRootLoggerConfigBuilder;
public class SearchLogging {
LoggerContext ctx = helper.getRootContext();
ctx.reset();
- LogbackHelper.RootLoggerConfig config = newRootLoggerConfigBuilder().setProcessId(ProcessId.ELASTICSEARCH).build();
+ RootLoggerConfig config = newRootLoggerConfigBuilder().setProcessId(ProcessId.ELASTICSEARCH).build();
String logPattern = helper.buildLogPattern(config);
helper.configureGlobalFileLog(props, config, logPattern);
import org.sonar.process.logging.LogbackHelper;
import org.sonar.process.ProcessId;
import org.sonar.process.Props;
+import org.sonar.process.logging.RootLoggerConfig;
import org.sonar.server.platform.ServerLogging;
-import static org.sonar.process.logging.LogbackHelper.RootLoggerConfig.newRootLoggerConfigBuilder;
+import static org.sonar.process.logging.RootLoggerConfig.newRootLoggerConfigBuilder;
public abstract class ServerProcessLogging {
protected static final Set<String> JMX_RMI_LOGGER_NAMES = ImmutableSet.of(
protected abstract void extendConfiguration(LogbackHelper helper, Props props);
private void configureRootLogger(Props props) {
- LogbackHelper.RootLoggerConfig config = newRootLoggerConfigBuilder()
+ RootLoggerConfig config = newRootLoggerConfigBuilder()
.setProcessId(processId)
.setThreadIdFieldPattern(threadIdFieldPattern)
.build();
import org.sonar.process.logging.LogbackHelper;
import org.sonar.process.ProcessId;
import org.sonar.process.Props;
+import org.sonar.process.logging.RootLoggerConfig;
import static org.slf4j.Logger.ROOT_LOGGER_NAME;
-import static org.sonar.process.logging.LogbackHelper.RootLoggerConfig.newRootLoggerConfigBuilder;
+import static org.sonar.process.logging.RootLoggerConfig.newRootLoggerConfigBuilder;
import static org.sonar.process.monitor.StreamGobbler.LOGGER_GOBBLER;
/**
private static final String CONSOLE_PLAIN_APPENDER = "CONSOLE";
private static final String APP_CONSOLE_APPENDER = "APP_CONSOLE";
private static final String GOBBLER_PLAIN_CONSOLE = "GOBBLER_CONSOLE";
- private static final LogbackHelper.RootLoggerConfig APP_ROOT_LOGGER_CONFIG = newRootLoggerConfigBuilder()
+ private static final RootLoggerConfig APP_ROOT_LOGGER_CONFIG = newRootLoggerConfigBuilder()
.setProcessId(ProcessId.APP)
.build();