Search in sources :

Example 81 with Logger

use of ch.qos.logback.classic.Logger in project netty by netty.

the class SingleThreadEventLoopTest method testRegistrationAfterShutdown.

@Test(timeout = 10000)
@SuppressWarnings("deprecation")
public void testRegistrationAfterShutdown() throws Exception {
    loopA.shutdown();
    // Disable logging temporarily.
    Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    List<Appender<ILoggingEvent>> appenders = new ArrayList<Appender<ILoggingEvent>>();
    for (Iterator<Appender<ILoggingEvent>> i = root.iteratorForAppenders(); i.hasNext(); ) {
        Appender<ILoggingEvent> a = i.next();
        appenders.add(a);
        root.detachAppender(a);
    }
    try {
        ChannelFuture f = loopA.register(new LocalChannel());
        f.awaitUninterruptibly();
        assertFalse(f.isSuccess());
        assertThat(f.cause(), is(instanceOf(RejectedExecutionException.class)));
        assertFalse(f.channel().isOpen());
    } finally {
        for (Appender<ILoggingEvent> a : appenders) {
            root.addAppender(a);
        }
    }
}
Also used : Appender(ch.qos.logback.core.Appender) LocalChannel(io.netty.channel.local.LocalChannel) ArrayList(java.util.ArrayList) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) Test(org.junit.Test)

Example 82 with Logger

use of ch.qos.logback.classic.Logger in project platformlayer by platformlayer.

the class LogbackHook method attachToRootLogger.

public static void attachToRootLogger() {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    LogbackHook appender = new LogbackHook();
    // PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    // encoder.setContext(loggerContext);
    // encoder.setPattern("%-4relative [%thread] %-5level %logger{35} - %msg%n");
    // encoder.start();
    // appender.setLayout(new PatternLayout("%d [%t] %-5p %c %x - %m%n"));
    appender.start();
    Logger logbackLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    logbackLogger.addAppender(appender);
}
Also used : Logger(ch.qos.logback.classic.Logger) LoggerContext(ch.qos.logback.classic.LoggerContext)

Example 83 with Logger

use of ch.qos.logback.classic.Logger in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method clear.

@Before
public void clear() {
    storage.clear();
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    when(mockAppender.getName()).thenReturn(CassandraSpanConsumerTest.class.getName());
    root.addAppender(mockAppender);
}
Also used : Logger(ch.qos.logback.classic.Logger) Before(org.junit.Before)

Example 84 with Logger

use of ch.qos.logback.classic.Logger in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method tearDown.

@After
public void tearDown() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.detachAppender(mockAppender);
}
Also used : Logger(ch.qos.logback.classic.Logger) After(org.junit.After)

Example 85 with Logger

use of ch.qos.logback.classic.Logger in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method tearDown.

@After
public void tearDown() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.detachAppender(mockAppender);
}
Also used : Logger(ch.qos.logback.classic.Logger) After(org.junit.After)

Aggregations

Logger (ch.qos.logback.classic.Logger)144 Test (org.junit.Test)49 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)45 LoggerContext (ch.qos.logback.classic.LoggerContext)40 FileAppender (ch.qos.logback.core.FileAppender)17 PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)16 Appender (ch.qos.logback.core.Appender)16 File (java.io.File)13 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)12 ArrayList (java.util.ArrayList)9 RollingFileAppender (ch.qos.logback.core.rolling.RollingFileAppender)8 AsyncLoggingEventAppenderFactory (io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory)8 DropwizardLayoutFactory (io.dropwizard.logging.layout.DropwizardLayoutFactory)7 Before (org.junit.Before)7 PipeConfiguration (co.cask.cdap.filetailer.config.PipeConfiguration)6 Query (org.apache.lucene.search.Query)6 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)6 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)6 Level (ch.qos.logback.classic.Level)5 Map (java.util.Map)5