Search in sources :

Example 16 with AsyncLoggingEventAppenderFactory

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());
}
Also used : Field(java.lang.reflect.Field) AsyncLoggingEventAppenderFactory(io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory) AsyncAppender(ch.qos.logback.classic.AsyncAppender) NullLevelFilterFactory(io.dropwizard.logging.filter.NullLevelFilterFactory) DropwizardLayoutFactory(io.dropwizard.logging.layout.DropwizardLayoutFactory) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerContext(ch.qos.logback.classic.LoggerContext) FileSize(ch.qos.logback.core.util.FileSize) Test(org.junit.Test)

Example 17 with AsyncLoggingEventAppenderFactory

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();
}
Also used : AsyncLoggingEventAppenderFactory(io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory) AsyncAppender(ch.qos.logback.classic.AsyncAppender) NullLevelFilterFactory(io.dropwizard.logging.filter.NullLevelFilterFactory) DropwizardLayoutFactory(io.dropwizard.logging.layout.DropwizardLayoutFactory) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerContext(ch.qos.logback.classic.LoggerContext) Test(org.junit.Test)

Example 18 with AsyncLoggingEventAppenderFactory

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();
}
Also used : AsyncLoggingEventAppenderFactory(io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory) AsyncAppender(ch.qos.logback.classic.AsyncAppender) NullLevelFilterFactory(io.dropwizard.logging.filter.NullLevelFilterFactory) DropwizardLayoutFactory(io.dropwizard.logging.layout.DropwizardLayoutFactory) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerContext(ch.qos.logback.classic.LoggerContext) Test(org.junit.Test)

Example 19 with AsyncLoggingEventAppenderFactory

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+\\].+");
}
Also used : AsyncLoggingEventAppenderFactory(io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory) AsyncAppender(ch.qos.logback.classic.AsyncAppender) NullLevelFilterFactory(io.dropwizard.logging.filter.NullLevelFilterFactory) SyslogAppender(ch.qos.logback.classic.net.SyslogAppender) DropwizardLayoutFactory(io.dropwizard.logging.layout.DropwizardLayoutFactory) LoggerContext(ch.qos.logback.classic.LoggerContext) Test(org.junit.Test)

Example 20 with AsyncLoggingEventAppenderFactory

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());
}
Also used : AsyncLoggingEventAppenderFactory(io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory) DropwizardLayoutFactory(io.dropwizard.logging.layout.DropwizardLayoutFactory) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) Test(org.junit.Test)

Aggregations

AsyncLoggingEventAppenderFactory (io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory)20 DropwizardLayoutFactory (io.dropwizard.logging.layout.DropwizardLayoutFactory)19 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)18 Test (org.junit.Test)17 LoggerContext (ch.qos.logback.classic.LoggerContext)12 NullLevelFilterFactory (io.dropwizard.logging.filter.NullLevelFilterFactory)12 AsyncAppender (ch.qos.logback.classic.AsyncAppender)11 Logger (ch.qos.logback.classic.Logger)9 SyslogAppender (ch.qos.logback.classic.net.SyslogAppender)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 AsyncAppenderFactory (io.dropwizard.logging.async.AsyncAppenderFactory)2 ThresholdLevelFilterFactory (io.dropwizard.logging.filter.ThresholdLevelFilterFactory)2 Map (java.util.Map)2 JMXConfigurator (ch.qos.logback.classic.jmx.JMXConfigurator)1 LevelChangePropagator (ch.qos.logback.classic.jul.LevelChangePropagator)1 CoreConstants (ch.qos.logback.core.CoreConstants)1 PatternLayoutBase (ch.qos.logback.core.pattern.PatternLayoutBase)1 AppenderAttachableImpl (ch.qos.logback.core.spi.AppenderAttachableImpl)1 FileSize (ch.qos.logback.core.util.FileSize)1 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1