Mule AnypointStudio中的记录错误

问题描述 投票:0回答:1

下面是配置文件。我要记录客户端错误。

我给它错误的文件名进行测试..并且它显示内部错误而不是非法路径。

并且我想分别记录该错误。

如果不是这种情况,请告诉其他方法以更好的方式登录。

请帮助我。

Client Side Error

Trying to log error message using dataweave

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" 
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" 
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core 
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule- 
http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule- 
file.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule- 
ee.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="e015780b- 
261c-480e-819a-4c753ae85c8d" >
    <http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<http:listener-config name="HTTP_Listener_config1" doc:name="HTTP Listener config" doc:id="9f4a053e-a0ee-47f0-abfd-7ca3c8b16ab5" >
    <http:listener-connection host="0.0.0.0" port="8082" />
</http:listener-config>
<http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="595e8959-30e1-477e-8ed4-694b062fca76" >
    <http:request-connection host="localhost" port="8082" />
</http:request-config>
<flow name="loggerexampleFlow" doc:id="a8465807-40c6-42ed-b6c2-4b2a899b16b4" >
    <http:listener doc:name="Listener" doc:id="41cb2867-747c-487a-b75b-06d601d47757" config-ref="HTTP_Listener_config" path="/log"/>
    <http:request method="GET" doc:name="Request" doc:id="00bc5953-30ba-4be7-be9b-fb78d2592aac" config-ref="HTTP_Request_configuration" path="/file"/>
    <logger level="INFO" doc:name="Logger" doc:id="bf2d639c-f973-45f5-a15d-2e8311fa1531" message="File read successfully"/>
</flow>
<flow name="loggerexampleFlow1" doc:id="109eb709-2c35-43a0-8f0c-bc612cff3a49" >
    <http:listener doc:name="Listener" doc:id="f5848ddf-5138-49ae-82b8-30a4263fb854" config-ref="HTTP_Listener_config1" path="/file"/>
    <file:read doc:name="Read" doc:id="dd94864b-5829-4a3a-9e08-9bdbda971ca0" path="C:\Users\SRI\Desktop\Work\Employee dat.xls">
        <error-mapping sourceType="FILE:ILLEGAL_PATH" targetType="APP:NOTFOUND" />
    </file:read>
    <ee:transform doc:name="Transform Message" doc:id="6ef5b05e-e044-4b33-a8be-05519f80f288">
        <ee:message>
        </ee:message>
            <ee:variables>
                <ee:set-variable variableName="Error"><![CDATA[%dw 2.0
     output application/json
     ---
    {
    Error: error.errorType
    }]]></ee:set-variable>
            </ee:variables>
    </ee:transform>
    <logger level="INFO" doc:name="Logger" doc:id="ddbc3e5d-a875-4427-b5b1-0b5a8881741b" message="# 
    [vars.Error]"/>
    </flow>
    </mule>
logging mule mule-studio mulesoft mule-esb
1个回答
0
投票

您的操作正确,但您应在错误处理部分进行此操作,并且应将其设置为错误继续。在此处查看示例https://simpleflatservice.com/mule4/OnErrorContinue.html

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.