在 ExecuteScript 处理器中使用 ProcessorLog 的最佳方法是什么?如果在处理过程中遇到错误,我计划向我的 groovy ExecuteScript 添加一些日志记录。但是,尝试添加日志没有成功。可能忽略了一些明显的东西。
代码片段:
import org.apache.commons.io.IOUtils
import java.nio.charset.*
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import org.apache.nifi.logging.ProcessorLog;
def flowFile = session.get()
if(!flowFile) return
def logger = getLogger();
错误
016-04-07 17:13:51,146 ERROR [Timer-Driven Process Thread-6] o.a.nifi.processors.script.ExecuteScript
org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getLogger() is applicable for argument types: () values: []
Possible solutions: getContext()
at org.apache.nifi.processors.script.ExecuteScript.onTrigger(ExecuteScript.java:205) ~[nifi-scripting-processors-0.5.1.jar:0.5.1]
at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1139) [nifi-framework-core-0.5.1.jar:0.5.1]
at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:139) [nifi-framework-core-0.5.1.jar:0.5.1]
at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:49) [nifi-framework-core-0.5.1.jar:0.5.1]
at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:124) [nifi-framework-core-0.5.1.jar:0.5.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_05]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_05]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_05]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_05]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_05]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_05]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_05]
Caused by: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getLogger() is applicable for argument types: () values: []