本文整理汇总了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;未经允许,请勿转载。 |
请发表评论