Enable Logging using Business Events
Section titled “Enable Logging using Business Events”Log your messages from Mule with the Custom Business Event element for complete visibility and control.
Features
Section titled “ Features”- Events
- Messages
- Context Properties
Configuration
Section titled “ Configuration”Always start your flows by initializing a session variable for reliable tracking and correlation.
Local Interchange ID
Section titled “ Local Interchange ID”runID

Session variable initialization for runID in Mule ESB.
Review the Mule ESB Correlation user guide for additional information.
BusinessEventHandlerListener
Section titled “BusinessEventHandlerListener”To capture business events in the log file, add the following XML snippet in the Mule Flow before the <flow> element.
<!-- Custom Business Events to log --><spring:beans> <spring:bean class="se.integrationsoftware.integrationmanager.BusinessEventHandlerListener" id="notificationListener" /></spring:beans><notifications> <notification-listener ref="notificationListener" /></notifications>
BusinessEventHandlerListener configuration in Mule.
The class se.integrationsoftware.integrationmanager.BusinessEventHandlerListener must also be included in your project.

Java package structure for the BusinessEventHandlerListener class.
package se.integrationsoftware.integrationmanager;
import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.mule.api.MuleContext;import org.mule.api.context.MuleContextAware;import com.mulesoft.mule.tracking.event.EventNotification;import com.mulesoft.mule.tracking.event.EventNotificationListener;
public class BusinessEventHandlerListener implements EventNotificationListener<EventNotification>, MuleContextAware{ MuleContext context;
protected static final Log logger = LogFactory.getLog("IMLog");
@Override public void onNotification(EventNotification notification) { String metaDatas = notification.getMetaDatas().toString(); if (metaDatas != null) { if (metaDatas.startsWith("{")) { metaDatas = metaDatas.substring(1); } if (metaDatas.endsWith("}")) { metaDatas = metaDatas.substring(0, metaDatas.length() - 1); } }
logger.info(metaDatas); }
@Override public void setMuleContext(MuleContext context) { this.context = context; }}Mule ESB Flow - Custom Business Event element
Section titled “Mule ESB Flow - Custom Business Event element”Utilize the Custom Business Event element in the Mule Flow to log messages to Nodinite.

Custom Business Event element in Mule ESB.
Configure the Business Event element:

Configuration of the Custom Business Event element.
<tracking:custom-event event-name="IMLog" doc:name="Custom Business Event"> <tracking:meta-data key="im_logText" value="File received"/> <tracking:meta-data key="im_endPointName" value="File transfer business event receive"/> <tracking:meta-data key="im_endPointDirection" value="Receive"/> <tracking:meta-data key="im_messageContext" value="#[message]"/> <tracking:meta-data key="im_messageBody" value="#[message.payloadAs(java.lang.String)]"/> </tracking:custom-event>Supported Properties
Section titled “ Supported Properties”- im_logText – Informal text, Optional
- im_endPointName – The Endpoint name, Mandatory
- im_endPointDirection – The Endpoint direction, Valid values are: None, Unknown, Receive, Send, TwoWayReceive, TwoWaySend
- im_endPointTypeId – The Endpoint type id, Integer see below for valid codes, Optional
- im_endPointUri – The Endpoint URI, Optional (overrides the Endpoint URI set by the log agent)
- im_messageType – The Message Type, Optional
- im_messageContext – The message context properties, #[message], Optional
- im_messageContextCustom – Custom message context properties, key value pair of type <string,string> (e.g., {"transactionId":"FA0CAE5C-8968-44DF-836D-1DAA57D7831B","orderId":"1234"}), Optional
- im_messageBody – The message payload, #[message.payloadAs(java.lang.String)], Optional
- im_logStatusCode – The message status, Signed integer, Optional
- im_integrationName – The name of the Integration. If this value is provided together with im_serviceName and/or im_contractName this Integration will be set for the Service and/or Contract, Optional
- im_serviceName – The name of the Service. A Transport Contract is created with Message Type and Endpoint, if im_contractName is set only the Message Type will be set on the Transport Contract, Optional
- im_serviceDirection – The direction of the Service, if not set the direction of the Endpoint will be used, Optional
- im_serviceSystemName – The name of the System used for the Service, Optional
- im_contractName – The name of the Contract. If this value is provided together with im_serviceName, the service will be set on the Contract, A Transport Contract is created with Message Type and Endpoint, Optional
- im_contractSystemName – The name of the System used for the Contract, Optional
Nodinite logs an event if all mandatory properties exist. It can extract the message type automatically from XML messages.
Log status code can be used to highlight errors, for example, in a Mule exception handling element.
Log exception information with #[groovy:message.getExceptionPayload().getException().getCause()] and #[groovy:message.getExceptionPayload().getException()]
EndpointTypeId
Section titled “EndpointTypeId”These codes are valid codes to be used with the im_endPointTypeId property.
See the list of Endpoint Types for available id:s to use
Next Steps
Section titled “ Next Steps” Add or manage Log View
Add or manage Log Agents
Related Topics
Section titled “ Related Topics” Log Views
Log Agents
Install Mule Log Agent
Configuration of the agent