Search in sources :

Example 6 with AsyncAppender

use of ch.qos.logback.classic.AsyncAppender 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();
}
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 7 with AsyncAppender

use of ch.qos.logback.classic.AsyncAppender 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();
}
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 8 with AsyncAppender

use of ch.qos.logback.classic.AsyncAppender 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();
}
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 9 with AsyncAppender

use of ch.qos.logback.classic.AsyncAppender 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 10 with AsyncAppender

use of ch.qos.logback.classic.AsyncAppender 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)

Aggregations

AsyncAppender (ch.qos.logback.classic.AsyncAppender)12 LoggerContext (ch.qos.logback.classic.LoggerContext)11 AsyncLoggingEventAppenderFactory (io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory)11 NullLevelFilterFactory (io.dropwizard.logging.filter.NullLevelFilterFactory)11 DropwizardLayoutFactory (io.dropwizard.logging.layout.DropwizardLayoutFactory)11 Test (org.junit.Test)11 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)10 SyslogAppender (ch.qos.logback.classic.net.SyslogAppender)2 Logger (ch.qos.logback.classic.Logger)1 Appender (ch.qos.logback.core.Appender)1 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)1 FileSize (ch.qos.logback.core.util.FileSize)1 InstrumentedAppender (com.codahale.metrics.logback.InstrumentedAppender)1 Field (java.lang.reflect.Field)1