Reading Time: 6 minutes

3.1 introduces a very useful new orchestration capabilities of Mule 3 flows, we found a real need for fine-grained logging. With the new message processor architecture, this was a snap and we were able to put together the new functionality in an afternoon. In this blog post I'll take you on a quick tour of what you can do with it with some examples.

Let's start with the basics and work through some examples:

How do I log a message at a certain point in my flow or service?

latest report
Learn why we are the Leaders in management and


    
    

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.

What if I want to escalate the severity of the message?

Simply add the ‘level' attribute, if you are using the Mule IDE editor,  you will see a list of the valid options: ERROR, WARN, INFO, DEBUG and TRACE.

The above example uses the wire tap configured with an expression filter to log our message using the ERROR level only when the incoming payload does not contain a certain string. Using an expression filter like this allows you to generate a log message only for specific conditions.

Thats great, but how can log specific information rather than the whole MuleMessage?

This is just a very simple example, by embedding Mule Expressions there is no limit to what you can output in your log message.  For example, if the message payload is XML, you could use an XPath expression to log a specific element of the message. Make sure you take a look at the expression reference guide.

Can I use my own log Category rather than the default org.mule.api.processor.LoggerMessageProcessor?

Yes, just configure the category you would like used with the ‘category' attribute.

downloading Mule 3.1.0-RC2JIRA.