use of ch.qos.logback.classic.AsyncAppender in project dropwizard by dropwizard.
the class FileAppenderFactoryTest method isNotNeverBlock.
@Test
public void isNotNeverBlock() throws Exception {
FileAppenderFactory<ILoggingEvent> fileAppenderFactory = new FileAppenderFactory<>();
fileAppenderFactory.setArchive(false);
fileAppenderFactory.setNeverBlock(false);
AsyncAppender asyncAppender = (AsyncAppender) fileAppenderFactory.build(new LoggerContext(), "test", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(asyncAppender.isNeverBlock()).isFalse();
}
use of ch.qos.logback.classic.AsyncAppender in project dropwizard by dropwizard.
the class SyslogAppenderFactoryTest method patternIncludesAppNameAndPid.
@Test
public void patternIncludesAppNameAndPid() throws Exception {
final AsyncAppender wrapper = (AsyncAppender) new SyslogAppenderFactory().build(new LoggerContext(), "MyApplication", new DropwizardLayoutFactory(), new NullLevelFilterFactory<>(), new AsyncLoggingEventAppenderFactory());
assertThat(((SyslogAppender) wrapper.getAppender("syslog-appender")).getSuffixPattern()).matches("^MyApplication\\[\\d+\\].+");
}
use of ch.qos.logback.classic.AsyncAppender in project uplace.es by Uplace.
the class LoggingConfiguration method addLogstashAppender.
private void addLogstashAppender(LoggerContext context) {
log.info("Initializing Logstash logging");
LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender();
logstashAppender.setName(LOGSTASH_APPENDER_NAME);
logstashAppender.setContext(context);
String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";
// More documentation is available at: https://github.com/logstash/logstash-logback-encoder
LogstashEncoder logstashEncoder = new LogstashEncoder();
// Set the Logstash appender config from JHipster properties
logstashEncoder.setCustomFields(customFields);
// Set the Logstash appender config from JHipster properties
logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(), jHipsterProperties.getLogging().getLogstash().getPort()));
ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
throwableConverter.setRootCauseFirst(true);
logstashEncoder.setThrowableConverter(throwableConverter);
logstashEncoder.setCustomFields(customFields);
logstashAppender.setEncoder(logstashEncoder);
logstashAppender.start();
// Wrap the appender in an Async appender for performance
AsyncAppender asyncLogstashAppender = new AsyncAppender();
asyncLogstashAppender.setContext(context);
asyncLogstashAppender.setName(ASYNC_LOGSTASH_APPENDER_NAME);
asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
asyncLogstashAppender.addAppender(logstashAppender);
asyncLogstashAppender.start();
context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
Aggregations