Replacing JaninoEventEvaluator #888
Unanswered
stephan-roolvink
asked this question in
Q&A
Replies: 2 comments
-
In general, it should be fairly easy to migrate the functionality of a I suggest to subclass For example, here is an evaluator class approximating your example above. import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.core.boolex.EvaluationException;
import ch.qos.logback.core.boolex.EventEvaluatorBase;
public class ExceptionMatchEvaluator extends EventEvaluatorBase<ILoggingEvent> {
String exceptionClass;
private boolean start = false;
public void start() {
if (exceptionClass == null) {
addError("The exceptionClass must be set");
return;
}
start = true;
}
public void stop() {
start = false;
}
public boolean isStarted() {
return start;
}
@Override
public boolean evaluate(ILoggingEvent event) throws NullPointerException, EvaluationException {
IThrowableProxy throwableProxy = event.getThrowableProxy();
if (throwableProxy == null) {
return false;
}
return throwableProxy.getClassName().equalsIgnoreCase(exceptionClass);
}
public String getExceptionClass() {
return exceptionClass;
}
public void setExceptionClass(String exceptionClass) {
this.exceptionClass = exceptionClass;
}
} And here is a sample logback.xml configuration file screening for <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> |
Beta Was this translation helpful? Give feedback.
0 replies
-
Added Documentation will be updated shortly |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In 1.5.13 the JaninoEventEvaluator was removed, I'm seeing that documentation regarding creating filters has not been updated, but I really would like to change my filters so they work with 1.5.13 and beyond. Is there somebody who can help me out?
Out filter looks like this now
Beta Was this translation helpful? Give feedback.
All reactions