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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanevaluate(ILoggingEvent event) Evaluates whether the event passed as parameter matches some user-specified criteria.booleanvoidsetExceptionClass(String exceptionClass) voidstart()voidstop()Methods inherited from class ch.qos.logback.core.boolex.EventEvaluatorBase
getName, setNameMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
startin interfaceLifeCycle- Overrides:
startin classEventEvaluatorBase<ILoggingEvent>
-
stop
- Specified by:
stopin interfaceLifeCycle- Overrides:
stopin classEventEvaluatorBase<ILoggingEvent>
-
isStarted
- Specified by:
isStartedin interfaceLifeCycle- Overrides:
isStartedin classEventEvaluatorBase<ILoggingEvent>
-
evaluate
Description copied from interface:EventEvaluatorEvaluates whether the event passed as parameter matches some user-specified criteria.The
Evaluatoris 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
-