use of ch.qos.logback.core.Appender in project gocd by gocd.
the class FileLocationProvider method asJson.
@Override
public Map<String, Object> asJson() {
LinkedHashMap<String, Object> json = new LinkedHashMap<>();
json.put("loc.config.dir", systemEnvironment.configDir().getAbsolutePath());
List<Logger> loggers = LOGGER_CONTEXT.getLoggerList();
Appender[] appenders = getAppenders(loggers);
for (int i = 0; i < appenders.length; i++) {
Appender appender = appenders[i];
if (!isFileAppender(appender)) {
continue;
}
FileAppender fileAppender = (FileAppender) appender;
File logFile = new File(fileAppender.rawFileProperty());
json.put("loc.log.root." + i, new File(logFile.getAbsolutePath()).getParent());
json.put("loc.log.basename." + i, logFile.getName());
}
return json;
}
use of ch.qos.logback.core.Appender 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);
}
}
}
use of ch.qos.logback.core.Appender 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);
}
}
}
use of ch.qos.logback.core.Appender in project sonarqube by SonarSource.
the class CeProcessLoggingTest method startup_logger_prints_to_only_to_system_out.
@Test
public void startup_logger_prints_to_only_to_system_out() {
LoggerContext ctx = underTest.configure(props);
Logger startup = ctx.getLogger("startup");
assertThat(startup.isAdditive()).isFalse();
Appender appender = startup.getAppender("CONSOLE");
assertThat(appender).isInstanceOf(ConsoleAppender.class);
ConsoleAppender<ILoggingEvent> consoleAppender = (ConsoleAppender<ILoggingEvent>) appender;
assertThat(consoleAppender.getTarget()).isEqualTo("System.out");
assertThat(consoleAppender.getEncoder()).isInstanceOf(PatternLayoutEncoder.class);
PatternLayoutEncoder patternEncoder = (PatternLayoutEncoder) consoleAppender.getEncoder();
assertThat(patternEncoder.getPattern()).isEqualTo("%d{yyyy.MM.dd HH:mm:ss} %-5level app[][%logger{20}] %msg%n");
}
use of ch.qos.logback.core.Appender in project sonarqube by SonarSource.
the class WebServerProcessLoggingTest method do_not_log_to_console.
@Test
public void do_not_log_to_console() {
LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(Logger.ROOT_LOGGER_NAME);
Appender appender = root.getAppender("CONSOLE");
assertThat(appender).isNull();
}
Aggregations