Java 类io.dropwizard.logging.layout.LayoutFactory 实例源码

项目:stroom-query    文件:FifoLogbackAppenderFactory.java   
@Override
public Appender<E> build(final LoggerContext context,
                         final String applicationName,
                         final LayoutFactory<E> layoutFactory,
                         final LevelFilterFactory<E> levelFilterFactory,
                         final AsyncAppenderFactory<E> asyncAppenderFactory) {
    final Appender<E> appender = new FifoLogbackAppender<>();

    appender.setContext(context);

    appender.addFilter(levelFilterFactory.build(threshold));
    getFilterFactories().forEach(f -> appender.addFilter(f.build()));
    appender.start();
    appender.setName(APPENDER_NAME);

    return appender;
}
项目:sam    文件:JsonLogAppender.java   
public Appender<ILoggingEvent> build(
    LoggerContext context,
    String applicationName,
    LayoutFactory<ILoggingEvent> layoutFactory,
    LevelFilterFactory<ILoggingEvent> levelFilterFactory,
    AsyncAppenderFactory<ILoggingEvent> asyncAppenderFactory
  ) {

  final LoggingEventCompositeJsonEncoder encoder = new LoggingEventCompositeJsonEncoder();
  encoder.setContext(context);

  encoder.getProviders().addProvider(withPattern("{ \"type\": \"system\" }", new LoggingEventPatternJsonProvider(), context));
  encoder.getProviders().addProvider(withName("timestamp", new LoggingEventFormattedTimestampJsonProvider(), context));
  encoder.getProviders().addProvider(new LogLevelJsonProvider() );
  encoder.getProviders().addProvider(new MessageJsonProvider() );
  encoder.getProviders().addProvider(new StackTraceJsonProvider() );

  encoder.start();

  final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
  appender.setContext(context);
  appender.setEncoder(encoder);
  appender.start();

  return wrapAsync(appender, asyncAppenderFactory);
}
项目:dropwizard-papertrail    文件:PapertrailAppenderFactory.java   
@Override
public Appender<ILoggingEvent> build(LoggerContext context,
                      String applicationName,
                      LayoutFactory<ILoggingEvent> layoutFactory,
                      LevelFilterFactory<ILoggingEvent> levelFilterFactory,
                      AsyncAppenderFactory<ILoggingEvent> asyncAppenderFactory) {
    final Syslog4jAppender<ILoggingEvent> syslogAppender = new Syslog4jAppender<>();
    syslogAppender.setContext(context);
    syslogAppender.setLayout(buildLayout(context, layoutFactory));
    syslogAppender.setName("SYSLOG-TLS");
    final SSLTCPNetSyslogConfig syslogConfig = new SSLTCPNetSyslogConfig();

    syslogConfig.setIdent(ident);
    syslogConfig.setHost(host);
    syslogConfig.setPort(port);
    syslogConfig.setFacility(facility);
    syslogConfig.setSendLocalName(sendLocalName);

    syslogAppender.setSyslogConfig(syslogConfig);

    syslogAppender.addFilter(levelFilterFactory.build(threshold));
    syslogAppender.start();

    return syslogAppender;
}
项目:stroom-query    文件:KafkaLogbackAppenderFactory.java   
@Override
public Appender<E> build(final LoggerContext context,
                      final String applicationName,
                      final LayoutFactory<E> layoutFactory,
                      final LevelFilterFactory<E> levelFilterFactory,
                      final AsyncAppenderFactory<E> asyncAppenderFactory) {

    final Properties producerConfigProperties = producerConfig.stream()
            .map(s -> s.split("="))
            .filter(values -> values.length == 2)
            .reduce(new Properties(), (props, values) -> {
                props.setProperty(values[0], values[1]);
                return props;
            }, (p1, p2) -> {
                Properties merged = new Properties();
                merged.putAll(p1);
                merged.putAll(p2);
                return merged;
            });

    final Appender<E> appender = new KafkaLogbackAppender<>(producerConfigProperties, topic);

    appender.setContext(context);

    appender.addFilter(levelFilterFactory.build(threshold));
    getFilterFactories().forEach(f -> appender.addFilter(f.build()));
    appender.start();
    appender.setName(APPENDER_NAME);

    return appender;
    //return wrapAsync(appender, asyncAppenderFactory);
}
项目:sam    文件:JsonAccessLogAppender.java   
public Appender<IAccessEvent> build(
    LoggerContext context,
    String applicationName,
    LayoutFactory<IAccessEvent> layoutFactory,
    LevelFilterFactory<IAccessEvent> levelFilterFactory,
    AsyncAppenderFactory<IAccessEvent> asyncAppenderFactory
  ) {

  final AccessEventCompositeJsonEncoder encoder = new AccessEventCompositeJsonEncoder();
  encoder.setContext(context);

  encoder.getProviders().addProvider(withPattern("{ \"type\": \"access\" }", new AccessEventPatternJsonProvider(), context));
  encoder.getProviders().addProvider(withName("timestamp" ,new AccessEventFormattedTimestampJsonProvider(), context));
  encoder.getProviders().addProvider(withName("status", new StatusCodeJsonProvider(), context));
  encoder.getProviders().addProvider(withName("method", new MethodJsonProvider(), context));
  encoder.getProviders().addProvider(withName("protocol", new ProtocolJsonProvider(), context));
  encoder.getProviders().addProvider(withName("uri", new RequestedUriJsonProvider(), context));
  encoder.getProviders().addProvider(withName("client-ip", new RemoteHostJsonProvider(), context));
  encoder.getProviders().addProvider(withName("user", new RemoteUserJsonProvider(), context));
  encoder.getProviders().addProvider(withName("elapsed-time", new ElapsedTimeJsonProvider(), context));
  encoder.getProviders().addProvider(withName("content-length", new ContentLengthJsonProvider(), context));
  encoder.getProviders().addProvider(withPattern("{ \"user-agent\": \"%i{User-Agent}\" }", new AccessEventPatternJsonProvider(), context));
  encoder.start();

  final ConsoleAppender<IAccessEvent> appender = new ConsoleAppender<>();
  appender.setContext(context);
  appender.setEncoder(encoder);
  appender.start();

  return wrapAsync(appender, asyncAppenderFactory);
}
项目:sys-api    文件:TextAreaAppenderFactory.java   
public Appender build(LoggerContext loggerContext, String s, LayoutFactory layoutFactory, LevelFilterFactory levelFilterFactory, AsyncAppenderFactory asyncAppenderFactory) {
    final TextAreaAppender appender = new TextAreaAppender();
    appender.setName("textarea-appender");
    appender.setContext(loggerContext);
    appender.start();
    return wrapAsync(appender, asyncAppenderFactory);
}
项目:dropwizard-logstash-encoder    文件:LogstashSocketAppenderFactory.java   
@Override
public Appender build(LoggerContext context, String s, LayoutFactory layoutFactory,
                      LevelFilterFactory levelFilterFactory,
                      AsyncAppenderFactory asyncAppenderFactory) {
  final LogstashSocketAppender appender = new LogstashSocketAppender();

  appender.setName("logstash-socket-appender");
  appender.setContext(context);
  appender.setHost(host);
  appender.setPort(port);

  appender.setIncludeCallerData(includeCallerData);
  appender.setIncludeMdc(includeMdc);
  appender.setIncludeContext(includeContext);

  if (customFields != null) {
    LogstashAppenderFactoryHelper
        .getCustomFieldsFromHashMap(customFields)
        .ifPresent(appender::setCustomFields);
  }

  if (fieldNames != null) {
    appender.setFieldNames(LogstashAppenderFactoryHelper.getFieldNamesFromHashMap(fieldNames));
  }

  appender.addFilter(levelFilterFactory.build(threshold));
  appender.start();

  return wrapAsync(appender, asyncAppenderFactory);
}
项目:dropwizard-logstash-encoder    文件:LogstashTcpAppenderFactory.java   
@Override
public Appender build(LoggerContext context, String s, LayoutFactory layoutFactory,
                      LevelFilterFactory levelFilterFactory,
                      AsyncAppenderFactory asyncAppenderFactory) {
  final LogstashTcpSocketAppender appender = new LogstashTcpSocketAppender();
  final LogstashEncoder encoder = new LogstashEncoder();

  appender.setName("logstash-tcp-appender");
  appender.setContext(context);
  appender.addDestinations(new InetSocketAddress(host, port));
  appender.setIncludeCallerData(includeCallerData);
  appender.setQueueSize(queueSize);

  encoder.setIncludeContext(includeContext);
  encoder.setIncludeMdc(includeMdc);
  encoder.setIncludeCallerData(includeCallerData);

  if (customFields != null) {
    LogstashAppenderFactoryHelper
        .getCustomFieldsFromHashMap(customFields)
        .ifPresent(encoder::setCustomFields);
  }

  if (fieldNames != null) {
    encoder.setFieldNames(LogstashAppenderFactoryHelper.getFieldNamesFromHashMap(fieldNames));
  }

  appender.setEncoder(encoder);
  appender.addFilter(levelFilterFactory.build(threshold));
  encoder.start();
  appender.start();

  return wrapAsync(appender, asyncAppenderFactory);
}
项目:dropwizard-raven    文件:RavenAppenderFactory.java   
@Override
public Appender<ILoggingEvent> build(LoggerContext context,
    String applicationName,
    LayoutFactory<ILoggingEvent> layoutFactory,
    LevelFilterFactory<ILoggingEvent> levelFilterFactory,
    AsyncAppenderFactory<ILoggingEvent> asyncAppenderFactory) {
  checkNotNull(context);

  final SentryAppender appender = new SentryAppender();
  appender.setName(APPENDER_NAME);
  appender.setContext(context);
  appender.setDsn(dsn);

  environment.ifPresent(appender::setEnvironment);
  extraTags.ifPresent(appender::setExtraTags);
  ravenFactory.ifPresent(appender::setRavenFactory);
  release.ifPresent(appender::setRelease);
  serverName.ifPresent(appender::setServerName);
  tags.ifPresent(appender::setTags);

  appender.addFilter(levelFilterFactory.build(threshold));
  getFilterFactories().stream().forEach(f -> appender.addFilter(f.build()));
  appender.start();

  final Appender<ILoggingEvent> asyncAppender = wrapAsync(appender, asyncAppenderFactory, context);
  addDroppingRavenLoggingFilter(asyncAppender);

  return asyncAppender;
}