use of io.dropwizard.logging.filter.NullLevelFilterFactory 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();
}
use of io.dropwizard.logging.filter.NullLevelFilterFactory in project dropwizard by dropwizard.
the class LogbackClassicRequestLogFactory method build.
public RequestLog build(String name) {
final Logger logger = (Logger) LoggerFactory.getLogger("http.request");
logger.setAdditive(false);
final LoggerContext context = logger.getLoggerContext();
final LevelFilterFactory<ILoggingEvent> levelFilterFactory = new NullLevelFilterFactory<>();
final AsyncAppenderFactory<ILoggingEvent> asyncAppenderFactory = new AsyncLoggingEventAppenderFactory();
final LayoutFactory<ILoggingEvent> layoutFactory = (c, tz) -> new RequestLogLayout();
final AppenderAttachableImpl<ILoggingEvent> attachable = new AppenderAttachableImpl<>();
for (AppenderFactory<ILoggingEvent> appender : appenders) {
attachable.addAppender(appender.build(context, name, layoutFactory, levelFilterFactory, asyncAppenderFactory));
}
return new DropwizardSlf4jRequestLog(attachable, timeZone);
}
use of io.dropwizard.logging.filter.NullLevelFilterFactory in project dropwizard by dropwizard.
the class ConsoleAppenderFactoryTest method defaultIsNotNeverBlock.
@Test
public void defaultIsNotNeverBlock() throws Exception {
ConsoleAppenderFactory<ILoggingEvent> consoleAppenderFactory = new ConsoleAppenderFactory<>();
// default neverBlock
AsyncAppender asyncAppender = (AsyncAppender) consoleAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isNeverBlock()).isFalse();
}
use of io.dropwizard.logging.filter.NullLevelFilterFactory in project dropwizard by dropwizard.
the class ConsoleAppenderFactoryTest method isNotNeverBlock.
@Test
public void isNotNeverBlock() throws Exception {
ConsoleAppenderFactory<ILoggingEvent> consoleAppenderFactory = new ConsoleAppenderFactory<>();
consoleAppenderFactory.setNeverBlock(false);
AsyncAppender asyncAppender = (AsyncAppender) consoleAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isNeverBlock()).isFalse();
}
use of io.dropwizard.logging.filter.NullLevelFilterFactory 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());
}
Aggregations