微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Nifi登录中创建自定义日志文件时出错

如何解决在Nifi登录中创建自定义日志文件时出错

我正在尝试为我在Nifi中的流程创建自定义日志文件;实现我想使用回退过滤器。

在我的logback.conf中,添加一个名为LLAB_FILE的新附加程序,该附加程序按其内容过滤了日志消息:

<appender name="LLAB_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${org.apache.nifi.bootstrap.config.log.dir}/llab-transform.log</file>
    <filter class="ch.qos.logback.core.filter.EvaluatorFilter">      
      <evaluator>
        <expression>return message.contains("LLAB_TRANSFORM");</expression>
      </evaluator>
      <OnMismatch>DENY</OnMismatch>
      <OnMatch>ACCEPT</OnMatch>
    </filter>
    <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
        <fileNamePattern>${org.apache.nifi.bootstrap.config.log.dir}/llab-transform_%d.%i.log</fileNamePattern>
        <maxFileSize>100MB</maxFileSize>
        <maxHistory>30</maxHistory>
    </rollingPolicy>
    <immediateFlush>true</immediateFlush>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>%date~%level~%msg%n</pattern>
    </encoder>
</appender>

<root level="INFO">
    <appender-ref ref="LLAB_FILE"/>
</root>

但是,当Nifi启动时,此配置会出现以下错误

Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: org/codehaus/janino/ScriptEvaluator
        at ch.qos.logback.core.boolex.JaninoEventEvaluatorBase.start(JaninoEventEvaluatorBase.java:57)
        at ch.qos.logback.core.joran.action.nestedComplexPropertyIA.end(nestedComplexPropertyIA.java:161)
        at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
        at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
        at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
        at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
        at ch.qos.logback.classic.util.Contextinitializer.configureByResource(Contextinitializer.java:75)
        at ch.qos.logback.classic.util.Contextinitializer.autoConfig(Contextinitializer.java:150)
        at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
        at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
        at org.apache.nifi.bootstrap.RunNiFi.<init>(RunNiFi.java:134)
        at org.apache.nifi.bootstrap.RunNiFi.main(RunNiFi.java:231)
Caused by: java.lang.classNotFoundException: org.codehaus.janino.ScriptEvaluator
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.classLoader.loadClass(ClassLoader.java:522)
        ... 20 more
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/janino/ScriptEvaluator
        at ch.qos.logback.core.boolex.JaninoEventEvaluatorBase.start(JaninoEventEvaluatorBase.java:57)
        at ch.qos.logback.core.joran.action.nestedComplexPropertyIA.end(nestedComplexPropertyIA.java:161)
        at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
        at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
        at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
        at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
        at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
        at ch.qos.logback.classic.util.Contextinitializer.configureByResource(Contextinitializer.java:75)
        at ch.qos.logback.classic.util.Contextinitializer.autoConfig(Contextinitializer.java:150)
        at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
        at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
        at org.apache.nifi.bootstrap.RunNiFi.<init>(RunNiFi.java:134)
        at org.apache.nifi.bootstrap.RunNiFi.main(RunNiFi.java:231)
Caused by: java.lang.classNotFoundException: org.codehaus.janino.ScriptEvaluator
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.classLoader.loadClass(ClassLoader.java:522)

我该如何解决?我不想处理日志引发nifi的流。

谢谢, 温度

解决方法

http://logback.qos.ch/manual/filters.html#JaninoEventEvaluator

JaninoEventEvaluator需要Janino library

请参阅设置文档的corresponding section


实际上,任何评估者都需要附加库

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。