Logger Element for Flows
Mule has always supported flows with <log-component>, but as of Mule 3.1, a new implementation called <logger> has been baked into the message processor for use anywhere within a flow.
Where Can <logger> Be Used?
- Anywhere in a <flow>
- Within inbound and outbound endpoint elements (or within their optional <response> elements)
How Do I Use <logger> at a Certain Point in a Flow?
Add <logger> at the point where you want to log the message:
This will log the message specified using the default DEBUG level, so you will see this in your log only if you have your log level set at DEBUG or TRACE level.
How Does <logger> Work Using WARN/ERROR?
Add the 'level' attribute. An XML editor should show you the permissible values: ERROR, WARN, INFO, DEBUG and TRACE.
This example uses the a wire tap configured with an expression filter to log our message using the ERROR category only when the incoming payload does not contain a certain string.
How Can I Log the Entire Message Payload?
In order to log your message payload, headers, the whole message or a single value from within your payload, <logger> leverages Mule Expressions. Rather than specifying a single expression for logging you can embed as many expressions as you required in your log ‘message’ as required. This allows you to give some context to what is being logged, and enables you to log multiple things at once.
Modifying and Expanding <logger>
Because you can use Mule Expressions, you can endlessly vary the output of your log messages. You can also configure <logger> to use your own category instead of using the givens within LoggerMessageProcessor.