use of ch.qos.logback.classic.spi.LoggerContextListener 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.spi.LoggerContextListener in project spring-boot by spring-projects.
the class LogbackLoggingSystemTests method initializationIsOnlyPerformedOnceUntilCleanedUp.
@Test
public void initializationIsOnlyPerformedOnceUntilCleanedUp() throws Exception {
LoggerContext loggerContext = (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory();
LoggerContextListener listener = mock(LoggerContextListener.class);
loggerContext.addListener(listener);
this.loggingSystem.beforeInitialize();
this.loggingSystem.initialize(this.initializationContext, null, null);
this.loggingSystem.beforeInitialize();
this.loggingSystem.initialize(this.initializationContext, null, null);
verify(listener, times(1)).onReset(loggerContext);
this.loggingSystem.cleanUp();
loggerContext.addListener(listener);
this.loggingSystem.beforeInitialize();
this.loggingSystem.initialize(this.initializationContext, null, null);
verify(listener, times(2)).onReset(loggerContext);
}
Aggregations