loggingmulemule-studiomulesoftmule-esb

Logging errors in Mule AnypointStudio


Below is configuration file. I want to log the client side error.

I have given wrong file name to test it.. and it is showing internal error instead of illegal path.

and I want to log separately that error.

Please tell the other methods to log in better way if not this.

Please help me.

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>

Solution

  • You are doing it right except you should do it in the Error handling section and it should be On Error Continue.