Message Logging


Message Logging policy is used to logs custom message between policy and flow. We can log information related to request or response. This comes quite handy in case where we want to capture request/response related logs for debugging without changing the code in mule application.

Warning: If the payload is used as part of the logging message or conditional expression while using non repeatable streams, the payload will be consumed by the policy.

Like for below HTTP listener if streaming strategy is change to Non repeatable stream then payload will be lost when request is received by the flow as stream will be consumed by the policy.

Message Logging


To Start with we will create a mule application and connect it with API manager – please see how we can connect the mulesoft application to API Manager

After deployment in Cloudhub the API manager configuration will come as Active

Message Logging


Now we will apply the policy

Message Logging


Select Message Logging

Message Logging


Now update the policy configuration

Message Logging

We can see below properties

  • Message – message we want to capture – define in dataweave expression
  • Conditional– condition based logging – define in dataweave expression
  • Category– categorized the capture logs
  • Level– log level
  • Before calling API – HTTP request releated logs
  • After calling API – HTTP request releated logs

Lets populate the field as per our need

We want to capture payload only when query param – destination is GOA

Message Logging


Click apply


Now if we test this API in SOAP UI


We can see the logs in Cloudhub


If we change the query param destination value then logs will not appear in Cloudhub

Sample application – sample-rest-service-message-logging

Sample SOAP UI project – sample-rest-service-xml-message-log-soapui-project

Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.

Share this:
Notify of
Inline Feedbacks
View all comments