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());
}
use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method testCurrentLogFileNameIsEmptyAndAppenderUsesArchivedNameInstead.
@Test
public void testCurrentLogFileNameIsEmptyAndAppenderUsesArchivedNameInstead() throws Exception {
final FileAppenderFactory<ILoggingEvent> appenderFactory = new FileAppenderFactory<>();
appenderFactory.setArchivedLogFilenamePattern(folder.newFile("test-archived-name-%d.log").toString());
final FileAppender<ILoggingEvent> rollingAppender = appenderFactory.buildAppender(new LoggerContext());
final String file = rollingAppender.getFile();
final String dateSuffix = LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-dd"));
final String name = Files.getNameWithoutExtension(file);
Assert.assertEquals("test-archived-name-" + dateSuffix, name);
}
use of ch.qos.logback.classic.LoggerContext in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method includesCallerData.
@Test
public void includesCallerData() {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
AsyncAppender asyncAppender = (AsyncAppender) fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isIncludeCallerData()).isFalse();
fileAppenderFactory.setIncludeCallerData(true);
asyncAppender = (AsyncAppender) fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isIncludeCallerData()).isTrue();
}
Aggregations