use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class ConsoleAppenderFactoryTest method includesCallerData.
@Test
public void includesCallerData() {
ConsoleAppenderFactory<ILoggingEvent> consoleAppenderFactory = new ConsoleAppenderFactory<>();
AsyncAppender asyncAppender = (AsyncAppender) consoleAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isIncludeCallerData()).isFalse();
consoleAppenderFactory.setIncludeCallerData(true);
asyncAppender = (AsyncAppender) consoleAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isIncludeCallerData()).isTrue();
}
use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class ConsoleAppenderFactoryTest method isNeverBlock.
@Test
public void isNeverBlock() throws Exception {
ConsoleAppenderFactory<ILoggingEvent> consoleAppenderFactory = new ConsoleAppenderFactory<>();
consoleAppenderFactory.setNeverBlock(true);
AsyncAppender asyncAppender = (AsyncAppender) consoleAppenderFactory.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 LogbackAccessRequestLogFactory method build.
@Override
public RequestLog build(String name) {
final Logger logger = (Logger) LoggerFactory.getLogger("http.request");
logger.setAdditive(false);
final LoggerContext context = logger.getLoggerContext();
final LogbackAccessRequestLog requestLog = new LogbackAccessRequestLog();
final LevelFilterFactory<IAccessEvent> levelFilterFactory = new NullLevelFilterFactory<>();
final AsyncAppenderFactory<IAccessEvent> asyncAppenderFactory = new AsyncAccessEventAppenderFactory();
final LayoutFactory<IAccessEvent> layoutFactory = new LogbackAccessRequestLayoutFactory();
for (AppenderFactory<IAccessEvent> output : appenders) {
requestLog.addAppender(output.build(context, name, layoutFactory, levelFilterFactory, asyncAppenderFactory));
}
return requestLog;
}
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);
}
Aggregations