use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method isNeverBlock.
@Test
public void isNeverBlock() throws Exception {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
fileAppenderFactory.setNeverBlock(true);
AsyncAppender asyncAppender = (AsyncAppender) fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isNeverBlock()).isTrue();
}
use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method isRolling.
@Test
public void isRolling() throws Exception {
// the method we want to test is protected, so we need to override it so we can see it
FileAppenderFactory fileAppenderFactory = new FileAppenderFactory<ILoggingEvent>() {
@Override
public FileAppender<ILoggingEvent> buildAppender(LoggerContext context) {
return super.buildAppender(context);
}
};
fileAppenderFactory.setCurrentLogFilename(folder.newFile("logfile.log").toString());
fileAppenderFactory.setArchive(true);
fileAppenderFactory.setArchivedLogFilenamePattern(folder.newFile("example-%d.log.gz").toString());
assertThat(fileAppenderFactory.buildAppender(new LoggerContext())).isInstanceOf(RollingFileAppender.class);
}
use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method isValidForInfiniteRolledFiles.
@Test
public void isValidForInfiniteRolledFiles() throws Exception {
FileAppenderFactory fileAppenderFactory = new FileAppenderFactory();
fileAppenderFactory.setCurrentLogFilename(folder.newFile("logfile.log").toString());
fileAppenderFactory.setArchivedFileCount(0);
fileAppenderFactory.setArchivedLogFilenamePattern(folder.newFile("example-%d.log.gz").toString());
ImmutableList<String> errors = ConstraintViolations.format(validator.validate(fileAppenderFactory));
assertThat(errors).isEmpty();
assertThat(fileAppenderFactory.buildAppender(new LoggerContext())).isNotNull();
}
use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class SyslogAppenderFactoryTest method stackTracePatternCanBeSet.
@Test
public void stackTracePatternCanBeSet() throws Exception {
final SyslogAppenderFactory syslogAppenderFactory = new SyslogAppenderFactory();
syslogAppenderFactory.setStackTracePrefix("--->");
final AsyncAppender wrapper = (AsyncAppender) syslogAppenderFactory.build(new LoggerContext(), "MyApplication", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(((SyslogAppender) wrapper.getAppender("syslog-appender")).getStackTracePattern()).isEqualTo("--->");
}
use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class DefaultLoggingFactoryPrintErrorMessagesTest method testWhenUsingDefaultConstructor_StaticILoggerFactoryIsSet.
@Test
public void testWhenUsingDefaultConstructor_StaticILoggerFactoryIsSet() throws Exception {
LoggerContext loggerContext = new DefaultLoggingFactory().getLoggerContext();
assertThat(loggerContext).isSameAs(LoggerFactory.getILoggerFactory());
}
Aggregations