use of io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method overrideBufferSize.
@Test
public void overrideBufferSize() throws NoSuchFieldException, IllegalAccessException {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
fileAppenderFactory.setBufferSize(Size.kilobytes(256));
AsyncAppender asyncAppender = (AsyncAppender) fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
final Appender<ILoggingEvent> fileAppender = asyncAppender.getAppender("file-appender");
assertThat(fileAppender).isInstanceOf(FileAppender.class);
final Field bufferSizeField = FileAppender.class.getDeclaredField("bufferSize");
bufferSizeField.setAccessible(true);
FileSize bufferSizeFromAppender = (FileSize) bufferSizeField.get(fileAppender);
assertThat(bufferSizeFromAppender.getSize()).isEqualTo(fileAppenderFactory.getBufferSize().toBytes());
}
use of io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method defaultIsNotNeverBlock.
@Test
public void defaultIsNotNeverBlock() throws Exception {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
// default neverBlock
AsyncAppender asyncAppender = (AsyncAppender) fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isNeverBlock()).isFalse();
}
use of io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method isNotNeverBlock.
@Test
public void isNotNeverBlock() throws Exception {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
fileAppenderFactory.setNeverBlock(false);
AsyncAppender asyncAppender = (AsyncAppender) fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isNeverBlock()).isFalse();
}
use of io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory in project dropwizard by dropwizard.
the class SyslogAppenderFactoryTest method patternIncludesAppNameAndPid.
@Test
public void patternIncludesAppNameAndPid() throws Exception {
final AsyncAppender wrapper = (AsyncAppender) new SyslogAppenderFactory().build(new LoggerContext(), "MyApplication", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(((SyslogAppender) wrapper.getAppender("syslog-appender")).getSuffixPattern()).matches("^MyApplication\\[\\d+\\].+");
}
use of io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory in project dropwizard by dropwizard.
the class SyslogAppenderFactoryTest method appenderContextIsSet.
@Test
public void appenderContextIsSet() throws Exception {
final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
final SyslogAppenderFactory appenderFactory = new SyslogAppenderFactory();
final Appender<ILoggingEvent> appender = appenderFactory.build(root.getLoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(appender.getContext()).isEqualTo(root.getLoggerContext());
}
Aggregations