use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class LogbackHelperTest method createRollingPolicy_defaults.
@Test
public void createRollingPolicy_defaults() {
LoggerContext ctx = underTest.getRootContext();
LogbackHelper.RollingPolicy policy = underTest.createRollingPolicy(ctx, props, "sonar");
FileAppender appender = policy.createAppender("SONAR_FILE");
assertThat(appender).isInstanceOf(RollingFileAppender.class);
// max 5 daily files
RollingFileAppender fileAppender = (RollingFileAppender) appender;
TimeBasedRollingPolicy triggeringPolicy = (TimeBasedRollingPolicy) fileAppender.getTriggeringPolicy();
assertThat(triggeringPolicy.getMaxHistory()).isEqualTo(7);
assertThat(triggeringPolicy.getFileNamePattern()).endsWith("sonar.%d{yyyy-MM-dd}.log");
}
use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class LogbackHelperTest method apply_sets_logger_to_INFO_if_no_property_is_set.
@Test
public void apply_sets_logger_to_INFO_if_no_property_is_set() {
LogLevelConfig config = LogLevelConfig.newBuilder().rootLevelFor(ProcessId.WEB_SERVER).build();
LoggerContext context = underTest.apply(config, props);
assertThat(context.getLogger(ROOT_LOGGER_NAME).getLevel()).isEqualTo(Level.INFO);
}
use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class LogbackHelperTest method enableJulChangePropagation.
@Test
public void enableJulChangePropagation() {
LoggerContext ctx = underTest.getRootContext();
int countListeners = ctx.getCopyOfListenerList().size();
LoggerContextListener propagator = underTest.enableJulChangePropagation(ctx);
assertThat(ctx.getCopyOfListenerList().size()).isEqualTo(countListeners + 1);
ctx.removeListener(propagator);
}
use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class SearchLogging method configure.
public LoggerContext configure(Props props) {
LoggerContext ctx = helper.getRootContext();
ctx.reset();
RootLoggerConfig config = newRootLoggerConfigBuilder().setProcessId(ProcessId.ELASTICSEARCH).build();
String logPattern = helper.buildLogPattern(config);
helper.configureGlobalFileLog(props, config, logPattern);
helper.configureForSubprocessGobbler(props, logPattern);
helper.apply(LogLevelConfig.newBuilder().rootLevelFor(ProcessId.ELASTICSEARCH).build(), props);
return ctx;
}
use of ch.qos.logback.classic.LoggerContext in project sonarqube by SonarSource.
the class SearchLoggingTest method do_not_log_to_console.
@Test
public void do_not_log_to_console() {
LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(ROOT_LOGGER_NAME);
Appender appender = root.getAppender("CONSOLE");
assertThat(appender).isNull();
}
Aggregations