Search in sources :

Example 76 with Logger

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

the class FileAppenderFactoryTest method appenderContextIsSet.

@Test
public void appenderContextIsSet() throws Exception {
    final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    final FileAppenderFactory<ILoggingEvent> appenderFactory = new FileAppenderFactory<>();
    appenderFactory.setArchivedLogFilenamePattern(folder.newFile("example-%d.log.gz").toString());
    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)

Example 77 with Logger

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

the class FileAppenderFactoryTest method appenderNameIsSet.

@Test
public void appenderNameIsSet() throws Exception {
    final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    final FileAppenderFactory<ILoggingEvent> appenderFactory = new FileAppenderFactory<>();
    appenderFactory.setArchivedLogFilenamePattern(folder.newFile("example-%d.log.gz").toString());
    final Appender<ILoggingEvent> appender = appenderFactory.build(root.getLoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
    assertThat(appender.getName()).isEqualTo("async-file-appender");
}
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)

Example 78 with Logger

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

Example 79 with Logger

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

the class StressTest method main.

public static void main(String[] args) throws Exception {
    Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.INFO);
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
    final int port = 8001;
    final int numClients = 10;
    new StressTestServer(port).start();
    System.out.println("Server running..");
    List<StressTestClient> clients = new ArrayList<StressTestClient>(numClients);
    for (int i = 0; i < numClients; i++) {
        StressTestClient client = new StressTestClient(port);
        client.connect();
        clients.add(client);
    }
    System.out.println("Waiting to disconnect all clients...");
    Thread.sleep(2 * 1000);
    System.out.println("Disconnecting all clients...");
    for (StressTestClient client : clients) {
        client.disconnect();
    }
    System.out.println("All clients disconnected!");
}
Also used : ArrayList(java.util.ArrayList) Logger(ch.qos.logback.classic.Logger) Slf4JLoggerFactory(org.jboss.netty.logging.Slf4JLoggerFactory)

Example 80 with Logger

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

the class SingleThreadEventLoopTest method testRegistrationAfterShutdown2.

@Test(timeout = 10000)
@SuppressWarnings("deprecation")
public void testRegistrationAfterShutdown2() throws Exception {
    loopA.shutdown();
    final CountDownLatch latch = new CountDownLatch(1);
    Channel ch = new LocalChannel();
    ChannelPromise promise = ch.newPromise();
    promise.addListener(new ChannelFutureListener() {

        @Override
        public void operationComplete(ChannelFuture future) throws Exception {
            latch.countDown();
        }
    });
    // 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(promise);
        f.awaitUninterruptibly();
        assertFalse(f.isSuccess());
        assertThat(f.cause(), is(instanceOf(RejectedExecutionException.class)));
        // Ensure the listener was notified.
        assertFalse(latch.await(1, TimeUnit.SECONDS));
        assertFalse(ch.isOpen());
    } finally {
        for (Appender<ILoggingEvent> a : appenders) {
            root.addAppender(a);
        }
    }
}
Also used : Appender(ch.qos.logback.core.Appender) LocalChannel(io.netty.channel.local.LocalChannel) LocalChannel(io.netty.channel.local.LocalChannel) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

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