java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.boolex.EventEvaluatorBase<ILoggingEvent>
ch.qos.logback.classic.boolex.ExceptionMatchEvaluator
- All Implemented Interfaces:
EventEvaluator<ILoggingEvent>
,ContextAware
,LifeCycle
A simple
EventEvaluator
that checks whether the
logging event being evaluated has a throwable of the same class as specified by the
exceptionClass
parameter.
Here is a
<configuration> <import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/> <import class="ch.qos.logback.core.filter.EvaluatorFilter"/> <import class="ch.qos.logback.classic.boolex.ExceptionMatchEvaluator"/> <import class="ch.qos.logback.core.ConsoleAppender"/> <appender name="CONSOLE" class="ConsoleAppender"> <filter class="EvaluatorFilter"> <evaluator class="ExceptionMatchEvaluator"> <exceptionClass>java.lang.RuntimeException</exceptionClass> </evaluator> <OnMismatch>DENY</OnMismatch> <OnMatch>NEUTRAL</OnMatch> </filter> <encoder class="PatternLayoutEncoder"> <pattern>%-4relative [%thread] %-5level %logger -%kvp -%msg%n</pattern> </encoder> </appender> <root level="INFO"> <appender-ref ref="CONSOLE"/> </root> </configuration>
-
Field Summary
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
evaluate
(ILoggingEvent event) Evaluates whether the event passed as parameter matches some user-specified criteria.boolean
void
setExceptionClass
(String exceptionClass) void
start()
void
stop()
Methods inherited from class ch.qos.logback.core.boolex.EventEvaluatorBase
getName, setName
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Constructor Details
-
ExceptionMatchEvaluator
public ExceptionMatchEvaluator()
-
-
Method Details
-
start
- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classEventEvaluatorBase<ILoggingEvent>
-
stop
- Specified by:
stop
in interfaceLifeCycle
- Overrides:
stop
in classEventEvaluatorBase<ILoggingEvent>
-
isStarted
- Specified by:
isStarted
in interfaceLifeCycle
- Overrides:
isStarted
in classEventEvaluatorBase<ILoggingEvent>
-
evaluate
Description copied from interface:EventEvaluator
Evaluates whether the event passed as parameter matches some user-specified criteria.The
Evaluator
is free to evaluate the event as it pleases. In particular, the evaluation results may depend on previous events.- Parameters:
event
- The event to evaluate- Returns:
- true if there is a match, false otherwise.
- Throws:
NullPointerException
- can be thrown in presence of null valuesEvaluationException
- may be thrown during faulty evaluation
-
getExceptionClass
-
setExceptionClass
-