Skip to content

Commit

Permalink
feat(core): custom log filter
Browse files Browse the repository at this point in the history
Since Logback 1.5.13, there is no more default implementation for the EvaluatorFilter so we need to supply our own.
See https://logback.qos.ch/manual/filters.html#evaluatorFilter
  • Loading branch information
loicmathieu committed Mar 10, 2025
1 parent 2d1582f commit 3ef1104
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
17 changes: 17 additions & 0 deletions core/src/main/java/io/kestra/core/log/KestraLogFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.kestra.core.log;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.boolex.EvaluationException;
import ch.qos.logback.core.boolex.EventEvaluatorBase;

public class KestraLogFilter extends EventEvaluatorBase<ILoggingEvent> {
@Override
public boolean evaluate(ILoggingEvent event) throws NullPointerException, EvaluationException {
var message = event.getMessage();
// as this filter is called very often, for perf,
// we use startWith and do all checks successfully instead of using a more elegant construct like Stream...
return message.startsWith("outOfOrder mode is active. Migration of schema") ||
message.startsWith("Version mismatch : Database version is older than what dialect POSTGRES supports") ||
message.startsWith("Failed to bind as java.util.concurrent.Executors$AutoShutdownDelegatedExecutorService is unsupported.");
}
}
8 changes: 1 addition & 7 deletions core/src/main/resources/logback/ecs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@
<level>WARN</level>
</filter>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression>
return message.contains("outOfOrder mode is active. Migration of schema") ||
message.contains("Database version is older than what dialect POSTGRES supports") ||
message.contains("Failed to bind as java.util.concurrent.Executors$AutoShutdownDelegatedExecutorService is unsupported.");
</expression>
</evaluator>
<evaluator class="io.kestra.core.log.KestraLogFilter" />
<OnMismatch>NEUTRAL</OnMismatch>
<OnMatch>DENY</OnMatch>
</filter>
Expand Down
8 changes: 1 addition & 7 deletions core/src/main/resources/logback/gcp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@
<level>WARN</level>
</filter>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression>
return message.contains("outOfOrder mode is active. Migration of schema") ||
message.contains("Database version is older than what dialect POSTGRES supports") ||
message.contains("Failed to bind as java.util.concurrent.Executors$AutoShutdownDelegatedExecutorService is unsupported.");
</expression>
</evaluator>
<evaluator class="io.kestra.core.log.KestraLogFilter" />
<OnMismatch>NEUTRAL</OnMismatch>
<OnMatch>DENY</OnMatch>
</filter>
Expand Down
14 changes: 1 addition & 13 deletions core/src/main/resources/logback/text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,7 @@
<level>WARN</level>
</filter>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<!--
- Disabling Liquibase outOfOrder warning
- Disabling JooQ POSTGRES version support warning, see https://github.com/kestra-io/kestra/issues/3321#issuecomment-2017665833
- Disabling Micronaut / Micrometer executor binding warning
Warning: this needs to also be done on gcp.xml and ecs.xml
-->
<expression>
return message.contains("outOfOrder mode is active. Migration of schema") ||
message.contains("Database version is older than what dialect POSTGRES supports") ||
message.contains("Failed to bind as java.util.concurrent.Executors$AutoShutdownDelegatedExecutorService is unsupported.");
</expression>
</evaluator>
<evaluator class="io.kestra.core.log.KestraLogFilter" />
<OnMismatch>NEUTRAL</OnMismatch>
<OnMatch>DENY</OnMatch>
</filter>
Expand Down

0 comments on commit 3ef1104

Please sign in to comment.