aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-11-18 10:39:53 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-11-18 11:06:39 +0100
commitdb80217f161ac24023e50bfb8c5628e436df6584 (patch)
tree984d5f901e8544737e1f3462c921905932aafd8d /server/sonar-process
parent1ab47e622a5f138b9d8e060457027a8d2cc30d08 (diff)
downloadsonarqube-db80217f161ac24023e50bfb8c5628e436df6584.tar.gz
sonarqube-db80217f161ac24023e50bfb8c5628e436df6584.zip
SONAR-8335 support global log level in ES JVM as we do for other JVM
Diffstat (limited to 'server/sonar-process')
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java28
1 files changed, 7 insertions, 21 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java b/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java
index c5ee0e2c66c..ac9351d8ad2 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java
@@ -39,7 +39,6 @@ import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
import javax.annotation.CheckForNull;
import org.apache.commons.lang.StringUtils;
@@ -107,7 +106,7 @@ public class LogbackHelper {
return new Builder();
}
- public ProcessId getProcessId() {
+ ProcessId getProcessId() {
return processId;
}
@@ -117,7 +116,7 @@ public class LogbackHelper {
public static final class Builder {
@CheckForNull
- public ProcessId processId;
+ private ProcessId processId;
private String threadIdFieldPattern = "";
private Builder() {
@@ -220,40 +219,27 @@ public class LogbackHelper {
return props.valueAsBoolean(ALL_LOGS_TO_CONSOLE_PROPERTY, false);
}
- @SafeVarargs
- private static <T> Set<T> setOf(T... args) {
- Set<T> res = new HashSet<>(args.length);
- res.addAll(Arrays.asList(args));
- return res;
- }
-
/**
* Configure the log level of the root logger reading the value of property {@link #SONAR_LOG_LEVEL_PROPERTY}.
*
* @throws IllegalArgumentException if the value of {@link #SONAR_LOG_LEVEL_PROPERTY} is not one of {@link #ALLOWED_ROOT_LOG_LEVELS}
*/
public Level configureRootLogLevel(Props props, ProcessId processId) {
- return configureRootLogLevel(props,
- SONAR_LOG_LEVEL_PROPERTY,
- SONAR_PROCESS_LOG_LEVEL_PROPERTY.replace(PROCESS_NAME_PLACEHOLDER, processId.getKey()));
+ Level newLevel = resolveLevel(props, SONAR_LOG_LEVEL_PROPERTY, SONAR_PROCESS_LOG_LEVEL_PROPERTY.replace(PROCESS_NAME_PLACEHOLDER, processId.getKey()));
+ getRootContext().getLogger(ROOT_LOGGER_NAME).setLevel(newLevel);
+ return newLevel;
}
/**
- * Configure the log level of the root logger reading the value of specified properties.
+ * Resolve a log level reading the value of specified properties.
* <p>
* To compute the applied log level the following rules will be followed:
* <ul>the last property with a defined and valid value in the order of the {@code propertyKeys} argument will be applied</ul>
- * <ul>if there is none, {@link Level#INFO INFO} will apply</ul>
+ * <ul>if there is none, {@link Level#INFO INFO} will be returned</ul>
* </p>
*
* @throws IllegalArgumentException if the value of the specified property is not one of {@link #ALLOWED_ROOT_LOG_LEVELS}
*/
- public Level configureRootLogLevel(Props props, String... propertyKeys) {
- Level newLevel = resolveLevel(props, propertyKeys);
- getRootContext().getLogger(ROOT_LOGGER_NAME).setLevel(newLevel);
- return newLevel;
- }
-
private static Level resolveLevel(Props props, String... propertyKeys) {
Level newLevel = Level.INFO;
for (String propertyKey : propertyKeys) {