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


Java OnMarkerEvaluator类代码示例

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


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

示例1: setMetricsMarkerLogbackFilter

import ch.qos.logback.classic.boolex.OnMarkerEvaluator; //导入依赖的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.classic.boolex.OnMarkerEvaluator; //导入依赖的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: auditLoggerInitializer

import ch.qos.logback.classic.boolex.OnMarkerEvaluator; //导入依赖的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.classic.boolex.OnMarkerEvaluator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。