Search in sources :

Example 1 with LayoutFactory

use of io.dropwizard.logging.layout.LayoutFactory in project dropwizard by dropwizard.

the class LogbackClassicRequestLogFactory method build.

public RequestLog build(String name) {
    final Logger logger = (Logger) LoggerFactory.getLogger("http.request");
    logger.setAdditive(false);
    final LoggerContext context = logger.getLoggerContext();
    final LevelFilterFactory<ILoggingEvent> levelFilterFactory = new NullLevelFilterFactory<>();
    final AsyncAppenderFactory<ILoggingEvent> asyncAppenderFactory = new AsyncLoggingEventAppenderFactory();
    final LayoutFactory<ILoggingEvent> layoutFactory = (c, tz) -> new RequestLogLayout();
    final AppenderAttachableImpl<ILoggingEvent> attachable = new AppenderAttachableImpl<>();
    for (AppenderFactory<ILoggingEvent> appender : appenders) {
        attachable.addAppender(appender.build(context, name, layoutFactory, levelFilterFactory, asyncAppenderFactory));
    }
    return new DropwizardSlf4jRequestLog(attachable, timeZone);
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ConsoleAppenderFactory(io.dropwizard.logging.ConsoleAppenderFactory) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerFactory(org.slf4j.LoggerFactory) AsyncLoggingEventAppenderFactory(io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory) LoggerContext(ch.qos.logback.classic.LoggerContext) Valid(javax.validation.Valid) JsonTypeName(com.fasterxml.jackson.annotation.JsonTypeName) RequestLogFactory(io.dropwizard.request.logging.RequestLogFactory) ImmutableList(com.google.common.collect.ImmutableList) NullLevelFilterFactory(io.dropwizard.logging.filter.NullLevelFilterFactory) Map(java.util.Map) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) CoreConstants(ch.qos.logback.core.CoreConstants) PatternLayoutBase(ch.qos.logback.core.pattern.PatternLayoutBase) AppenderAttachableImpl(ch.qos.logback.core.spi.AppenderAttachableImpl) RequestLog(org.eclipse.jetty.server.RequestLog) ImmutableMap(com.google.common.collect.ImmutableMap) LayoutFactory(io.dropwizard.logging.layout.LayoutFactory) TimeZone(java.util.TimeZone) AppenderFactory(io.dropwizard.logging.AppenderFactory) LevelFilterFactory(io.dropwizard.logging.filter.LevelFilterFactory) NotNull(javax.validation.constraints.NotNull) Logger(ch.qos.logback.classic.Logger) AsyncAppenderFactory(io.dropwizard.logging.async.AsyncAppenderFactory) NullLevelFilterFactory(io.dropwizard.logging.filter.NullLevelFilterFactory) AppenderAttachableImpl(ch.qos.logback.core.spi.AppenderAttachableImpl) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerContext(ch.qos.logback.classic.LoggerContext) AsyncLoggingEventAppenderFactory(io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory)

Aggregations

Logger (ch.qos.logback.classic.Logger)1 LoggerContext (ch.qos.logback.classic.LoggerContext)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 CoreConstants (ch.qos.logback.core.CoreConstants)1 PatternLayoutBase (ch.qos.logback.core.pattern.PatternLayoutBase)1 AppenderAttachableImpl (ch.qos.logback.core.spi.AppenderAttachableImpl)1 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 JsonTypeName (com.fasterxml.jackson.annotation.JsonTypeName)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 AppenderFactory (io.dropwizard.logging.AppenderFactory)1 ConsoleAppenderFactory (io.dropwizard.logging.ConsoleAppenderFactory)1 AsyncAppenderFactory (io.dropwizard.logging.async.AsyncAppenderFactory)1 AsyncLoggingEventAppenderFactory (io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory)1 LevelFilterFactory (io.dropwizard.logging.filter.LevelFilterFactory)1 NullLevelFilterFactory (io.dropwizard.logging.filter.NullLevelFilterFactory)1 LayoutFactory (io.dropwizard.logging.layout.LayoutFactory)1 RequestLogFactory (io.dropwizard.request.logging.RequestLogFactory)1 Map (java.util.Map)1