• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EvaluatorFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setMetricsMarkerLogbackFilter

import ch.qos.logback.core.filter.EvaluatorFilter; //导入依赖的package包/类
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
    log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
    OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
    onMarkerMetricsEvaluator.setContext(context);
    onMarkerMetricsEvaluator.addMarker("metrics");
    onMarkerMetricsEvaluator.start();
    EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
    metricsFilter.setContext(context);
    metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
    metricsFilter.setOnMatch(FilterReply.DENY);
    metricsFilter.start();

    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) {
            Appender<ILoggingEvent> appender = it.next();
            if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
                log.debug("Filter metrics logs from the {} appender", appender.getName());
                appender.setContext(context);
                appender.addFilter(metricsFilter);
                appender.start();
            }
        }
    }
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:25,代码来源:LoggingConfiguration.java


示例2: setMetricsMarkerLogbackFilter

import ch.qos.logback.core.filter.EvaluatorFilter; //导入依赖的package包/类
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
    log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
    OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
    onMarkerMetricsEvaluator.setContext(context);
    onMarkerMetricsEvaluator.addMarker("metrics");
    onMarkerMetricsEvaluator.start();
    EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
    metricsFilter.setContext(context);
    metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
    metricsFilter.setOnMatch(FilterReply.DENY);
    metricsFilter.start();

    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext(); ) {
            Appender<ILoggingEvent> appender = it.next();
            if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
                log.debug("Filter metrics logs from the {} appender", appender.getName());
                appender.setContext(context);
                appender.addFilter(metricsFilter);
                appender.start();
            }
        }
    }
}
 
开发者ID:asanzdiego,项目名称:codemotion-2017-taller-de-jhipster,代码行数:25,代码来源:LoggingConfiguration.java


示例3: evaluatorFilterWithNullMarker_LBCORE_118

import ch.qos.logback.core.filter.EvaluatorFilter; //导入依赖的package包/类
@Test
public void evaluatorFilterWithNullMarker_LBCORE_118() throws Exception {
  EvaluatorFilter<ILoggingEvent> ef = new EvaluatorFilter<ILoggingEvent>();
  ef.setContext(loggerContext);

  ef.setOnMatch(FilterReply.ACCEPT);
  ef.setOnMismatch(FilterReply.DENY);

  jee.setExpression("marker.contains(\"BLUE\")");
  jee.start();

  ef.setEvaluator(jee);
  ef.start();
  ILoggingEvent event = makeLoggingEvent(null);
  assertEquals(FilterReply.NEUTRAL, ef.decide(event));
  
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:JaninoEventEvaluatorTest.java


示例4: addDefaultNestedComponentRegistryRules

import ch.qos.logback.core.filter.EvaluatorFilter; //导入依赖的package包/类
static public void addDefaultNestedComponentRegistryRules(
    DefaultNestedComponentRegistry registry) {
  registry.add(AppenderBase.class, "layout", PatternLayout.class);
  registry.add(UnsynchronizedAppenderBase.class, "layout", PatternLayout.class);
  
  registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class);
  registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class);
  
  registry
      .add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class);

  SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:14,代码来源:DefaultNestedComponentRules.java


示例5: addDefaultNestedComponentRegistryRules

import ch.qos.logback.core.filter.EvaluatorFilter; //导入依赖的package包/类
@Override
protected void addDefaultNestedComponentRegistryRules(
    DefaultNestedComponentRegistry registry) {
  registry.add(AppenderBase.class, "layout", PatternLayout.class);
        registry
      .add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class);

  registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class);
  registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class);
  SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:12,代码来源:JoranConfigurator.java


示例6: auditLoggerInitializer

import ch.qos.logback.core.filter.EvaluatorFilter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static void auditLoggerInitializer(String filePath) {
    // This an instance of the LoggerFactory bound internally at runtime time.
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();


    // Check to see if using default configuration, if so don't output to console.
    if (loggerContext.getLoggerList().size() == 1) {
        Logger root = loggerContext.getLogger("ROOT");
        root.detachAppender("console");
    }

    // Just a simple pattern for outputting the messages, includes the ISO8601 formatted timestamp and marker.
    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(loggerContext);
    encoder.setPattern("[%d{ISO8601}] %msg%n");
    encoder.start();


    // This is the appender, the object that actually outputs to the file. It gets attached to the Logger.
    RollingFileAppender appender = new RollingFileAppender();
    appender.setName(ROTATE_APPENDER_NAME);
    appender.setContext(loggerContext);
    appender.setEncoder(encoder);
    configureAppender(filePath, appender);

    // Use the external rotate policy
    ExternalRotateRollingPolicy policy = new ExternalRotateRollingPolicy(appender);
    policy.setContext(loggerContext);
    policy.start();
    appender.setRollingPolicy(policy);

    // This filter checks each log for the AUDIT marker. It will only accept those logs with the AUDIT marker.
    EvaluatorFilter evalFilter= new EvaluatorFilter();
    OnMarkerEvaluator markerEval= new OnMarkerEvaluator();
    markerEval.addMarker("AUDIT");
    markerEval.start();
    evalFilter.setEvaluator(markerEval);
    evalFilter.setOnMatch(FilterReply.ACCEPT);
    evalFilter.setOnMismatch(FilterReply.DENY);
    evalFilter.start();
    appender.addFilter(evalFilter);

    // Get a new logger from the loggerContext then make sure there are no other appenders and attach rfAppender.
    logbackLogger.detachAndStopAllAppenders();
    appender.start();
    logbackLogger.addAppender(appender);
    logbackLogger.setLevel(Level.INFO);
    logbackLogger.setAdditive(false);
    hasInitialized = true;
}
 
开发者ID:ezbake,项目名称:ezbake-common-java,代码行数:52,代码来源:AuditLoggerConfigurator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BandwidthHistory类代码示例发布时间:2022-05-23
下一篇:
Java JEnumConstant类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap