Contact Us 1-800-596-4880

Logger Component

Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule reached its End of Life on November 2, 2022, when Extended Support ended.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

This Core component helps you monitor and debug your Mule application by logging important information such as error messages, status notifications, payloads, and so on. You can add a Logger anywhere in a flow, and you can configure it to log a string that you specify, the output of a DataWeave expression you write, or any combination of strings and expressions.

Keep in mind that the Logger is one of the only components that supports mixing Strings and expressions within a value. DataWeave String interpolation or concatenation within a single expression should be used elsewhere.

The configured messages are logged to the app’s log file, which is located in MULE_HOME/logs/<app-name>.log if no custom log file path is specified in the log4j2.xml file.
In Studio, the logs show in the Console.

The following example displays the message in Set Payload in a browser and also logs the message.

logger flow
Example: XML Configuration of the Flow
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081"/>
<flow name="logger-example-Flow">
  <http:listener config-ref="HTTP_Listener_Configuration" path="/"/>
  <set-payload value="Hello MuleSoft!"/>
  <logger message="#[payload]" level="INFO"/>
</flow>

Logger Configuration

logger
Field Value Description Example

Message

String or DataWeave expression

Specifies the Mule log message. By default, messages are logged to the application’s log file.

message="Current payload is #[payload]"

Level

Available options:

  • DEBUG

  • ERROR

  • INFO(Default)

  • TRACE

  • WARN

Specifies the log level.

level="ERROR"

Category

String

Optional setting that specifies a category name that it adds to log4j2.xml file. For example, you might use a category to route your log messages based on your category, or you might set log levels based on category.

category="MyCustomCategory"

Examples

This Logger is set to monitor message processing status, mixing Strings and expressions:

<logger category="monitoring" message="Message #[payload.id] processed successfully" level="INFO"/>

This Logger set to record the processing time of a flow, using a single expression and DataWeave’s String concatenation:

 <logger category="performance" message="#['Message ' ++ payload.id ++ ' took ' ++ vars.processingTime ++ ' milliseconds to process']" level="INFO"/>