当我在日志文件中使用 ch.qos.logback.core.filter.EvaluatorFilter 时,Gradle构建任务失败
登录文件示例
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator> <!-- defaults to type ch.qos.logback.classic.boolex.JaninoEventEvaluator -->
<expression>return formattedMessage.contains("myCustomString");</expression>
</evaluator>
<OnMismatch>NEUTRAL</OnMismatch>
<OnMatch>DENY</OnMatch>
</filter>
Stacktrace
> Task :compileTestJava
|-ERROR in ch.qos.logback.classic.boolex.JaninoEventEvaluator@628dfa31 - Could not start evaluator with expression [formattedMessage.contains("myCustomString"] org.codehaus.commons.compiler.CompileException: Line 1, Column 1: A class "ch.qos.logback.classic.Level" could not be found
at org.codehaus.commons.compiler.CompileException: Line 1, Column 1: A class "ch.qos.logback.classic.Level" could not be found
at at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:12055)
at at org.codehaus.janino.UnitCompiler.getSingleTypeImport(UnitCompiler.java:10606)
at at org.codehaus.janino.UnitCompiler.checkForConflictWithSingleTypeImport(UnitCompiler.java:452)
at at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:408)
at at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:225)
请注意,评估过滤器在运行应用程序时可以正常工作,并且在gradle项目中将使用日志记录过滤器的所有必需jar都定义为依赖项。