Logging 当我们在Groovy脚本mule 3.7.3中引发异常时,如何限制错误日志不打印在日志中

Logging 当我们在Groovy脚本mule 3.7.3中引发异常时,如何限制错误日志不打印在日志中,logging,groovy,mule,mule-studio,mule-component,Logging,Groovy,Mule,Mule Studio,Mule Component,当我们在Groovy脚本mule中引发异常时,如何限制错误日志不打印在日志中。 下面是流程和响应 <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="7475" doc:name="HTTP Listener Configuration"/> <flow name="ExceptionTestFlow"> <http

当我们在Groovy脚本mule中引发异常时,如何限制错误日志不打印在日志中。 下面是流程和响应

    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="7475" doc:name="HTTP Listener Configuration"/>
        <flow name="ExceptionTestFlow">
            <http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/>
            <logger level="INFO" doc:name="Logger"/>
            <scripting:component doc:name="Groovy">
                <scripting:script engine="Groovy"><![CDATA[throw new Exception("Invalid Message")]]></scripting:script>
            </scripting:component>
            <catch-exception-strategy doc:name="Catch Exception Strategy">
                <logger message="#[payload]" level="INFO" doc:name="Logger"/>
            </catch-exception-strategy>
        </flow>

Response as follows:

INFO  2017-02-09 12:13:52,928 [[ExceptionTest].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: 
org.mule.DefaultMuleMessage
{
  id=1efcb560-ee93-11e6-a87c-005056880d06
  payload=org.mule.transport.NullPayload
  correlationId=<not set>
  correlationGroup=-1
  correlationSeq=-1
  encoding=UTF-8
  exceptionPayload=<not set>

Message properties:
  INVOCATION scoped properties:
  INBOUND scoped properties:
    accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    accept-encoding=gzip, deflate, sdch, br
    accept-language=en-US,en;q=0.8
    connection=keep-alive
    host=localhost:7475
    http.listener.path=/test
    http.method=GET
    http.query.params=ParameterMap{[]}
    http.query.string=
    http.relative.path=/test
    http.remote.address=/127.0.0.1:60711
    http.request.path=/test
    http.request.uri=/test
    http.scheme=http
    http.uri.params=ParameterMap{[]}
    http.version=HTTP/1.1
    upgrade-insecure-requests=1
    user-agent=Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
  OUTBOUND scoped properties:
  SESSION scoped properties:
}
ERROR 2017-02-09 12:13:53,305 [[ExceptionTest].HTTP_Listener_Configuration.worker.01] org.mule.exception.CatchMessagingExceptionStrategy: 
********************************************************************************
Message               : Failed to invoke ScriptComponent{ExceptionTestFlow.component.693275170}. Component that caused exception is: ScriptComponent{ExceptionTestFlow.component.693275170}. Message payload is of type: NullPayload
Type                  : org.mule.component.ComponentException
Code                  : MULE_ERROR--2
JavaDoc               : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html
Payload               : {NullPayload}
********************************************************************************
Exception stack is:
1. Invalid Message (java.lang.Exception)
  sun.reflect.NativeConstructorAccessorImpl:-2 (null)
2. java.lang.Exception: Invalid Message (javax.script.ScriptException)
  org.codehaus.groovy.jsr223.GroovyScriptEngineImpl:326 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/script/ScriptException.html)
3. Failed to invoke ScriptComponent{ExceptionTestFlow.component.693275170}. Component that caused exception is: ScriptComponent{ExceptionTestFlow.component.693275170}. Message payload is of type: NullPayload (org.mule.component.ComponentException)
  org.mule.component.AbstractComponent:142 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
********************************************************************************
Root Exception stack trace:
java.lang.Exception: Invalid Message
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
      at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80)
      at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
      at Script1.run(Script1.groovy:1)
      at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:323)
      at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:44)
      at javax.script.CompiledScript.eval(CompiledScript.java:92)
      at org.mule.module.scripting.component.Scriptable.runScript(Scriptable.java:287)
      at org.mule.module.scripting.component.ScriptComponent.doInvoke(ScriptComponent.java:78)
      at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:120)
      at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:55)
      at org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:236)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
      at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.component.AbstractComponent.process(AbstractComponent.java:154)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
      at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
      at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
      at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:102)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
      at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
      at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:55)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
      at org.mule.processor.BlockingProce...
********************************************************************************

INFO  2017-02-09 12:13:53,334 [[ExceptionTest].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: null

答复如下:
信息2017-02-09 12:13:52928[[例外测试].HTTP\u Listener\u Configuration.worker.01]org.mule.api.processor.LoggerMessageProcessor:
org.mule.DefaultMuleMessage
{
id=1efcb560-ee93-11e6-a87c-005056880d06
有效载荷=org.mule.transport.NullPayload
相关ID=
correlationGroup=-1
correlationSeq=-1
编码=UTF-8
例外有效载荷=
消息属性:
调用范围的属性:
入站作用域属性:
accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
接受编码=gzip、deflate、sdch、br
接受语言=en US,en;q=0.8
连接=保持活动状态
主机=本地主机:7475
http.listener.path=/test
http.method=GET
http.query.params=ParameterMap{[]}
http.query.string=
http.relative.path=/test
http.remote.address=/127.0.0.1:60711
http.request.path=/test
http.request.uri=/test
scheme=http
http.uri.params=ParameterMap{[]}
http.version=http/1.1
升级不安全的请求=1
用户代理=Mozilla/5.0(Windows NT 6.3;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/55.0.2883.87 Safari/537.36
出站作用域属性:
会话作用域属性:
}
错误2017-02-09 12:13:53305[[ExceptionTest].HTTP\u Listener\u Configuration.worker.01]org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
消息:调用ScriptComponent{ExceptionTestFlow.component.693275170}失败。导致异常的组件是:ScriptComponent{ExceptionTestFlow.Component.693275170}。消息负载的类型为:NullPayload
类型:org.mule.component.ComponentException
代码:MULE_错误--2
JavaDoc:http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html
有效负载:{NullPayload}
********************************************************************************
异常堆栈是:
1.无效消息(java.lang.Exception)
sun.reflect.nativeConstructor附件MPL:-2(空)
2.java.lang.Exception:无效消息(javax.script.ScriptException)
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl:326(http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/script/ScriptException.html)
3.调用ScriptComponent{ExceptionTestFlow.component.693275170}失败。导致异常的组件是:ScriptComponent{ExceptionTestFlow.Component.693275170}。消息负载的类型为:NullPayload(org.mule.component.ComponentException)
org.mule.component.AbstractComponent:142(http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
********************************************************************************
根异常堆栈跟踪:
java.lang.Exception:无效消息
位于sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
位于java.lang.reflect.Constructor.newInstance(Constructor.java:422)
位于org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80)
位于org.codehaus.groovy.runtime.callsite.ConstructorSite$constructorsiteNounewrapnocerce.callConstructor(ConstructorSite.java:105)
位于org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
位于org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
位于org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
在Script1.run(Script1.groovy:1)
位于org.codehaus.groovy.jsr223.groovyScript EngineImpl.eval(groovyScript EngineImpl.java:323)
位于org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:44)
位于javax.script.CompiledScript.eval(CompiledScript.java:92)
位于org.mule.module.scripting.component.Scriptable.runScript(Scriptable.java:287)
位于org.mule.module.scripting.component.ScriptComponent.doInvoke(ScriptComponent.java:78)
位于org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:120)
访问org.mule.component.AbstractComponent.access$000(AbstractComponent.java:55)
位于org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:236)
位于org.mule.execution.exceptionMessaginExceptionExecutionInterceptor.execute(exceptionMessaginExceptionExecutionInterceptor.java:24)
位于org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
位于org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
位于org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
在org.mule.processor.BlockingProcessorExecutor.execute上(BlockingProcessorExecutor.java:59)
位于org.mule.execution.exceptionMessaginExceptionExecutionInterceptor.execute(exceptionMessaginExceptionExecutionInterceptor.java:24)
位于org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
位于org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
位于org.mule.component.AbstractComponent.process(AbstractComponent.java:154)
在org。
 <logger message="Exceptions message is ... #[org.mule.util.ExceptionUtils.getFullStackTrace(exception)]" level="ERROR"  doc:name="exceptionLogger"/>