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());
}
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");
}
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());
}
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!");
}
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);
}
}
}
Aggregations