当前位置: 首页>>代码示例>>Java>>正文


Java LogLevelJsonProvider类代码示例

本文整理汇总了Java中net.logstash.logback.composite.loggingevent.LogLevelJsonProvider的典型用法代码示例。如果您正苦于以下问题:Java LogLevelJsonProvider类的具体用法?Java LogLevelJsonProvider怎么用?Java LogLevelJsonProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LogLevelJsonProvider类属于net.logstash.logback.composite.loggingevent包,在下文中一共展示了LogLevelJsonProvider类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEncoder

import net.logstash.logback.composite.loggingevent.LogLevelJsonProvider; //导入依赖的package包/类
/**
 * Get a {@link LoggingEventCompositeJsonEncoder}. The returned appender
 * adds a timestamp field and sets the type to "servicelog" if serviceLog is
 * true. If set to false, we return a request log appender which sets the
 * timestamp field internally to guarantee that timestamp of the request log
 * event and the resultant json structure stay in sync.
 * @param loggerContext to use for setup
 * @param serviceLog return appender for service logs if true, else return one for request logs
 * @return corresponding {@link LoggingEventCompositeJsonEncoder}
 */
static LoggingEventCompositeJsonEncoder getEncoder(
        final LoggerContext loggerContext, final boolean serviceLog) {
    final LoggingEventCompositeJsonEncoder jsonEncoder = new LoggingEventCompositeJsonEncoder();
    jsonEncoder.setContext(loggerContext);
    final LoggingEventJsonProviders jsonProviders = getCommonJsonProviders(loggerContext);

    final GlobalCustomFieldsJsonProvider<ILoggingEvent> customFieldsJsonProvider
            = new GlobalCustomFieldsJsonProvider<>();
    if (serviceLog) {
        final LoggingEventFormattedTimestampJsonProvider timeStampProvider
                = new LoggingEventFormattedTimestampJsonProvider();
        timeStampProvider.setTimeZone(DateTimeZone.UTC.getID());
        timeStampProvider.setFieldName("timestamp");
        jsonProviders.addTimestamp(timeStampProvider);
        customFieldsJsonProvider.setCustomFields("{\"type\":\"servicelog\"}");
    } else {
        customFieldsJsonProvider.setCustomFields("{\"type\":\"requestlog\"}");
    }
    jsonProviders.addGlobalCustomFields(customFieldsJsonProvider);
    jsonProviders.addStackTrace(new StackTraceJsonProvider());
    jsonProviders.addLogLevel(new LogLevelJsonProvider());
    jsonEncoder.setProviders(jsonProviders);
    jsonEncoder.start();
    return jsonEncoder;
}
 
开发者ID:secondbase,项目名称:secondbase,代码行数:36,代码来源:SecondBaseLogger.java

示例2: overrideLogLevelProvider

import net.logstash.logback.composite.loggingevent.LogLevelJsonProvider; //导入依赖的package包/类
@Test
public void overrideLogLevelProvider() {
    SixtJsonEncoder encoder = new SixtJsonEncoder();
    JsonProviders<ILoggingEvent> providers = encoder.getProviders();
    int defaultCount = 0;
    int overrideCount = 0;

    for (JsonProvider<ILoggingEvent> provider : providers.getProviders()) {
        if (provider instanceof LogLevelJsonProvider &&
                !(provider instanceof CustomLogLevelJsonProvider)) {
            defaultCount++;
        } else if (provider instanceof CustomLogLevelJsonProvider) {
            overrideCount++;
        }
    }
    assertThat(defaultCount).isEqualTo(0);
    assertThat(overrideCount).isEqualTo(1);
}
 
开发者ID:Sixt,项目名称:ja-micro,代码行数:19,代码来源:SixtJsonEncoderTest.java

示例3: build

import net.logstash.logback.composite.loggingevent.LogLevelJsonProvider; //导入依赖的package包/类
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);
}
 
开发者ID:atgse,项目名称:sam,代码行数:27,代码来源:JsonLogAppender.java

示例4: removeDefaultProvider

import net.logstash.logback.composite.loggingevent.LogLevelJsonProvider; //导入依赖的package包/类
private void removeDefaultProvider(LoggingEventJsonProviders providers) {
    JsonProvider<ILoggingEvent> providerToDelete = null;

    for (JsonProvider<ILoggingEvent> provider : providers.getProviders()) {
        if (provider instanceof LogLevelJsonProvider) {
            providerToDelete = provider;
            break;
        }
    }

    providers.removeProvider(providerToDelete);
}
 
开发者ID:Sixt,项目名称:ja-micro,代码行数:13,代码来源:SixtJsonEncoder.java


注:本文中的net.logstash.logback.composite.loggingevent.LogLevelJsonProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。