use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class LogbackHelper method apply.
/**
* Applies the specified {@link LogLevelConfig} reading the specified {@link Props}.
*
* @throws IllegalArgumentException if the any level specified in a property is not one of {@link #ALLOWED_ROOT_LOG_LEVELS}
*/
public LoggerContext apply(LogLevelConfig logLevelConfig, Props props) {
LoggerContext rootContext = getRootContext();
logLevelConfig.getConfiguredByProperties().entrySet().forEach(entry -> applyLevelByProperty(props, rootContext.getLogger(entry.getKey()), entry.getValue()));
logLevelConfig.getConfiguredByHardcodedLevel().entrySet().forEach(entry -> applyHardcodedLevel(rootContext, entry.getKey(), entry.getValue()));
return rootContext;
}
use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class LogbackHelper method changeRoot.
public void changeRoot(LogLevelConfig logLevelConfig, Level newLevel) {
ensureSupportedLevel(newLevel);
LoggerContext rootContext = getRootContext();
rootContext.getLogger(ROOT_LOGGER_NAME).setLevel(newLevel);
logLevelConfig.getConfiguredByProperties().entrySet().forEach(entry -> rootContext.getLogger(entry.getKey()).setLevel(newLevel));
}
use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class LogbackHelper method resetFromXml.
/**
* Generally used to reset logback in logging tests
*/
public void resetFromXml(String xmlResourcePath) throws JoranException {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset();
configurator.doConfigure(LogbackHelper.class.getResource(xmlResourcePath));
}
use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class SearchLoggingTest method root_logger_level_changes_with_es_property.
@Test
public void root_logger_level_changes_with_es_property() {
props.set("sonar.log.level.es", "TRACE");
LoggerContext ctx = underTest.configure(props);
verifyRootLogLevel(ctx, Level.TRACE);
}
use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class ServerProcessLogging method configure.
public LoggerContext configure(Props props) {
LoggerContext ctx = helper.getRootContext();
ctx.reset();
helper.enableJulChangePropagation(ctx);
configureRootLogger(props);
helper.apply(logLevelConfig, props);
configureDirectToConsoleLoggers(ctx, STARTUP_LOGGER_NAME);
extendConfigure();
return ctx;
}
Aggregations