- 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
public class ExceptionMatchEvaluator extends EventEvaluatorBase<ILoggingEvent>
A simpleEventEvaluatorthat checks whether the logging event being evaluated has a throwable of the same class as specified by theexceptionClassparameter.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>- Since:
- 1.5.15
-
-
Field Summary
-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description ExceptionMatchEvaluator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanevaluate(ILoggingEvent event)Evaluates whether the event passed as parameter matches some user-specified criteria.StringgetExceptionClass()booleanisStarted()voidsetExceptionClass(String exceptionClass)voidstart()voidstop()-
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 Detail
-
ExceptionMatchEvaluator
public ExceptionMatchEvaluator()
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfaceLifeCycle- Overrides:
startin classEventEvaluatorBase<ILoggingEvent>
-
stop
public void stop()
- Specified by:
stopin interfaceLifeCycle- Overrides:
stopin classEventEvaluatorBase<ILoggingEvent>
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceLifeCycle- Overrides:
isStartedin classEventEvaluatorBase<ILoggingEvent>
-
evaluate
public boolean evaluate(ILoggingEvent event) throws NullPointerException, EvaluationException
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
public String getExceptionClass()
-
setExceptionClass
public void setExceptionClass(String exceptionClass)
-
-