use of ch.qos.logback.core.Appender in project atlasdb by palantir.
the class ProfilingKeyValueServiceTest method dropTableSlowLogPresentOnInfoLevel.
@Test
public void dropTableSlowLogPresentOnInfoLevel() {
Appender mockAppender = setLogLevelAndGetAppender(Level.INFO);
doAnswer(waitASecondAndAHalf).when(delegate).dropTable(any());
kvs.dropTable(TABLE_REF);
verify(mockAppender).doAppend(slowLogMatcher.get());
}
use of ch.qos.logback.core.Appender in project atlasdb by palantir.
the class ProfilingKeyValueServiceTest method dropTableTraceLogPresentOnTraceLevelEvenIfQueryIsSlow.
@Test
public void dropTableTraceLogPresentOnTraceLevelEvenIfQueryIsSlow() {
Appender mockAppender = setLogLevelAndGetAppender(Level.TRACE);
doAnswer(waitASecondAndAHalf).when(delegate).dropTable(any());
kvs.dropTable(TABLE_REF);
verify(mockAppender).doAppend(traceLogMatcher.get());
verify(mockAppender).doAppend(slowLogMatcher.get());
}
use of ch.qos.logback.core.Appender in project candlepin by candlepin.
the class StatusResourceTest method simulateVersionFilter.
@Test
public void simulateVersionFilter() throws Exception {
// setup logger to see if we actually log anything
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger srLogger = lc.getLogger(StatusResource.class);
Appender mockapp = mock(Appender.class);
srLogger.addAppender(mockapp);
srLogger.setLevel(Level.DEBUG);
ArgumentCaptor<LoggingEvent> message = ArgumentCaptor.forClass(LoggingEvent.class);
PrintStream ps = new PrintStream(new File(this.getClass().getClassLoader().getResource("version.properties").toURI()));
ps.println("version=${version}");
ps.println("release=${release}");
StatusResource sr = new StatusResource(rulesCurator, config, jsProvider, candlepinCache, modeManager);
Status s = sr.status();
ps.close();
// make sure we did not log anything which indicates
// an exception
verify(mockapp, never()).doAppend(message.capture());
assertEquals("${release}", s.getRelease());
assertEquals("${version}", s.getVersion());
assertTrue(s.getResult());
assertFalse(s.getStandalone());
}
use of ch.qos.logback.core.Appender in project kie-wb-common by kiegroup.
the class LogbackConfig method setSiftingAppender.
private SiftingAppender setSiftingAppender(LoggerContext loggerContext, Discriminator discriminator) {
KieSiftingAppender appender = new KieSiftingAppender();
appender.setName(MavenConfig.COMPILATION_ID);
appender.setDiscriminator(discriminator);
appender.setAppenderFactory(new AppenderFactory<ILoggingEvent>() {
@Override
public Appender<ILoggingEvent> buildAppender(Context context, String discriminatingValue) throws JoranException {
KieSiftingAppender kieAppender = new KieSiftingAppender();
kieAppender.setName(discriminatingValue);
kieAppender.setContext(loggerContext);
return kieAppender;
}
});
appender.setContext(loggerContext);
appender.start();
return appender;
}
use of ch.qos.logback.core.Appender in project cuba by cuba-platform.
the class LogControlImpl method getAppenderThreshold.
@Override
public Level getAppenderThreshold(String appenderName) throws AppenderThresholdNotSupported {
for (Map.Entry<String, Appender> entry : getAllAppenders().entrySet()) {
if (entry.getKey().equals(appenderName)) {
Appender appender = entry.getValue();
for (Object filter : appender.getCopyOfAttachedFiltersList()) {
if (filter instanceof ThresholdFilter) {
try {
Field field = filter.getClass().getDeclaredField("level");
field.setAccessible(true);
return (Level) field.get(filter);
} catch (NoSuchFieldException | IllegalAccessException e) {
log.error("Error getting appender " + appenderName + " level", e);
throw new AppenderThresholdNotSupported(appenderName);
}
}
}
}
}
throw new AppenderThresholdNotSupported(appenderName);
}
Aggregations