Message Logging Policy in MuleSoft

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:
- Select the Message Logging Policy from the Apply New Policy in the API Manager.

- 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:

- Give the request to the API.

- 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
Recent Blogs

Designing for Reality: Integrating 837 Claims When X12 Meets Production
Designing 837 Claim Integration for Real-World Healthcare Systems When it comes to 837 claim integration, most architects assume the X12 specification guarantees predictability. On paper, the 837 Professional, Institutional, and Dental transactions look clean and orderly. In production? Not even close. Real-world 837 files behave differently across trading partners. Loops appear conditionally. Repeatable segments shift… Continue reading Designing for Reality: Integrating 837 Claims When X12 Meets Production
Designing for Reality: Integrating 837 Claims When X12 Meets Production
Designing 837 Claim Integration for Real-World Healthcare Systems When it comes to 837 claim integration, most architects assume the X12 specification guarantees predictability. On paper, the 837 Professional, Institutional, and Dental transactions look clean and orderly. In production? Not even close. Real-world 837 files behave differently across trading partners. Loops appear conditionally. Repeatable segments shift… Continue reading Designing for Reality: Integrating 837 Claims When X12 Meets Production

AI-Driven PDF Parsing in Salesforce
Introduction For the current digital ecosystem, data is an important aspect for decision-making. Yet, for many organizations, a significant portion of this valuable data remains locked away in unstructured formats. Organizations handle thousands of PDF documents daily — ranging from contracts and invoices to lab reports, quotations, and service agreements. Traditionally, extracting structured data from… Continue reading AI-Driven PDF Parsing in Salesforce
AI-Driven PDF Parsing in Salesforce
Introduction For the current digital ecosystem, data is an important aspect for decision-making. Yet, for many organizations, a significant portion of this valuable data remains locked away in unstructured formats. Organizations handle thousands of PDF documents daily — ranging from contracts and invoices to lab reports, quotations, and service agreements. Traditionally, extracting structured data from… Continue reading AI-Driven PDF Parsing in Salesforce

Compression Namespace in Apex: A Powerful New Salesforce Feature
Introduction Working with documents inside Salesforce has always challenged developers because of the platform’s multitenant constraints. Previously, packaging and sending files in a compact form required external services, like an AWS Lambda function, that retrieved files via API and then compressed them. With the introduction of the Compression Namespace and the powerful pre-defined Apex functions,… Continue reading Compression Namespace in Apex: A Powerful New Salesforce Feature
Compression Namespace in Apex: A Powerful New Salesforce Feature
Introduction Working with documents inside Salesforce has always challenged developers because of the platform’s multitenant constraints. Previously, packaging and sending files in a compact form required external services, like an AWS Lambda function, that retrieved files via API and then compressed them. With the introduction of the Compression Namespace and the powerful pre-defined Apex functions,… Continue reading Compression Namespace in Apex: A Powerful New Salesforce Feature

Boost LWC Performance with Debouncing
Introduction Lightning Web Components (LWC) is a modern framework for building fast and dynamic user interfaces on the Salesforce platform. However, one common challenge in web development, including LWC, is efficiently handling user input, especially when dealing with rapid or repetitive events, such as typing in a search field. This is where debouncing becomes an… Continue reading Boost LWC Performance with Debouncing
Boost LWC Performance with Debouncing
Introduction Lightning Web Components (LWC) is a modern framework for building fast and dynamic user interfaces on the Salesforce platform. However, one common challenge in web development, including LWC, is efficiently handling user input, especially when dealing with rapid or repetitive events, such as typing in a search field. This is where debouncing becomes an… Continue reading Boost LWC Performance with Debouncing