MuleSoft Technical Guides

Message Logging Policy in MuleSoft

User MuleSoft Integration Team
Calendar June 30, 2021

The Message Logging policy logs custom messages from incoming requests, responses from the backend, or information from other policies applied to the same API endpoint.

Steps to implement the Message Logging Policy:

  1. Select the Message Logging Policy from the Apply New Policy in the API Manager.

message logging Mule

  1. Now specify the type of content you want to log. Fill the Parameters accordingly :

 

 

Message A DataWeave expression to use for extracting the message to be logged.
Conditional A DataWeave Boolean expression used to specify whether a message is to be logged
Category A prefix in the log message that indicates the package and class where the log is executed. If no category is set, the default value is org.mule.runtime.logging.policy-<policy id>.
Level Defines the level of message to log: INFO, WARN, ERROR, or DEBUG
Before Calling API Set to cause your logging policy to log messages before the API endpoint is called, taking into account the order in which this policy is applied
After Calling API Set to cause your logging policy to log messages after the API endpoint is called, taking into account the order in which this policy is applied

Suppose we want to log the payload; accordingly, we need to set the parameters as shown in the image below:

MuleSoft Message logging Policy

  1. Give the request to the API.

Mule Message Logging Policy

  1.  Now open the Logs of the API.

Anypoint Platform -> Runtime Manager -> API -> Logs,

We can see the payload in the logs, which is similar to what we got while requesting the API.

Thanks for reading. Learn more from certified MuleSoft Experts here at Caelius Consulting Resource Centre

 

 

 

Leave a comment

Your email address will not be published. Required fields are marked *