Replacing JaninoEventEvaluator #888
Replies: 6 comments 1 reply
-
Update: An online tool called Janino expression migrator was deployed earlier today, January 5th 2025. It should help users migrate their configuration files using 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.
-
Added Documentation will be updated shortly |
Beta Was this translation helpful? Give feedback.
-
I had some problems with JaninoEventEvaluator after updating |
Beta Was this translation helpful? Give feedback.
-
@Cesaario Your comment seems unrelated to the issue at hand, namely the removal of JaninoEventEvaluator. May I suggest to create a new discussion? |
Beta Was this translation helpful? Give feedback.
-
@stephan-roolvink An online tool called Janino expression migrator was deployed earlier today, January 5th 2025. It should help users migrate their configuration files using |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer I was aware of creating an evaluator for this, I was hoping for a way to avoid it as it add more code to maintain. |
Beta Was this translation helpful? Give feedback.
-
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