---
title: Enable Logging from Mule ESB Flows Using Business Events with Nodinite – Complete Guide
description: Enable powerful logging from Mule ESB flows using Business Events with Nodinite. Learn how to capture, monitor, and analyze business-critical events for seamless integration and troubleshooting.
---

# Enable Logging using Business Events

>Log your messages from Mule with the Custom Business Event element for complete visibility and control. <i class="fal fa-bolt" aria-hidden="true"></i> <i class="fal fa-search" aria-hidden="true"></i>

<aside aria-label="Note" class="nodinite-note nodinite-note--note">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-note"></i> Note</p>
<div class="nodinite-note__content"><p>Custom Business Events are only available in <strong>Mule ESB Enterprise Edition</strong></p></div>
</aside>

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p>For even more advanced features, consider using the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Logging <a href="https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/features/custom-connector/">Custom Connector</a> instead of Business Events.</p></div>
</aside>

## <i class="fal fa-ballot-check" aria-hidden="true"></i> Features

* Events
  * Messages
  * Context Properties

## <i class="fal fa-edit" aria-hidden="true"></i> Configuration

Always start your flows by initializing a session variable for reliable tracking and correlation.

### <i class="fal fa-link" aria-hidden="true"></i> Local Interchange ID

**runID**  
![sessionvariable][2]  
*Session variable initialization for runID in Mule ESB.*  

Review the [Mule ESB Correlation][] user guide for additional information.

### BusinessEventHandlerListener

To capture business events in the log file, add the following XML snippet in the Mule Flow before the `<flow>` element.  

```xml
<!-- Custom Business Events to log -->
<spring:beans>
    <spring:bean class="se.integrationsoftware.integrationmanager.BusinessEventHandlerListener" id="notificationListener" />
</spring:beans>
<notifications>
    <notification-listener ref="notificationListener" />
</notifications>
```

![CustomBusinessEvent_HandlerListener][CustomBusinessEvent_HandlerListener]  
*BusinessEventHandlerListener configuration in Mule.*  

The class **se.integrationsoftware.integrationmanager.BusinessEventHandlerListener** must also be included in your project.  

![JavaPackage_Studio][JavaPackage_Studio]  
*Java package structure for the BusinessEventHandlerListener class.*  

```java
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

Utilize the Custom Business Event element in the Mule Flow to log messages to <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>.

![CustomBusinessEvent_Element][CustomBusinessEvent_Element]  
*Custom Business Event element in Mule ESB.*

Configure the Business Event element:

![CustomBusinessEvent_Configuration][CustomBusinessEvent_Configuration]  
*Configuration of the Custom Business Event element.*

```xml
        <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>
```

## <i class="fal fa-tags" aria-hidden="true"></i> Supported Properties

* <i class="fal fa-align-left" aria-hidden="true"></i> **im_logText** – Informal text, Optional
* <i class="fal fa-tag" aria-hidden="true"></i> **im_endPointName** – The Endpoint name, Mandatory
* <i class="fal fa-arrow-right-arrow-left" aria-hidden="true"></i> **im_endPointDirection** – The Endpoint direction, Valid values are: **None**, **Unknown**, **Receive**, **Send**, **TwoWayReceive**, **TwoWaySend**
* <i class="fal fa-network-wired" aria-hidden="true"></i> **im_endPointTypeId** – The Endpoint type id, **Integer** see below for valid codes, Optional
* <i class="fal fa-link" aria-hidden="true"></i> **im_endPointUri** – The Endpoint URI, Optional (overrides the Endpoint URI set by the log agent)
* <i class="fal fa-envelope" aria-hidden="true"></i> **im_messageType** – The [Message Type][Message Types], Optional
* <i class="fal fa-list" aria-hidden="true"></i> **im_messageContext** – The message context properties, **#[message]**, Optional
* <i class="fal fa-list-ul" aria-hidden="true"></i> **im_messageContextCustom** – Custom message context properties, key value pair of type <string,string> (e.g., {"transactionId":"FA0CAE5C-8968-44DF-836D-1DAA57D7831B","orderId":"1234"}), Optional
* <i class="fal fa-file-lines" aria-hidden="true"></i> **im_messageBody** – The message payload, **#[message.payloadAs(java.lang.String)]**, Optional
* <i class="fal fa-traffic-light" aria-hidden="true"></i> **im_logStatusCode** – The message status, **Signed integer**, Optional
* <i class="fal fa-object-group" aria-hidden="true"></i> **im_integrationName** – The name of the [Integration][Integrations]. If this value is provided together with **im_serviceName** and/or **im_contractName** this Integration will be set for the [Service][Services] and/or [Contract][Contracts], Optional
* <i class="fal fa-gears" aria-hidden="true"></i> **im_serviceName** – The name of the [Service][Services]. A Transport Contract is created with Message Type and [Endpoint][Endpoints], if **im_contractName** is set only the Message Type will be set on the Transport Contract, Optional
* <i class="fal fa-arrow-right-arrow-left" aria-hidden="true"></i> **im_serviceDirection** – The direction of the Service, if not set the direction of the Endpoint will be used, Optional
* <i class="fal fa-desktop" aria-hidden="true"></i> **im_serviceSystemName** – The name of the [System][Systems] used for the Service, Optional
* <i class="fal fa-file-contract" aria-hidden="true"></i> **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
* <i class="fal fa-desktop" aria-hidden="true"></i> **im_contractSystemName** – The name of the System used for the Contract, Optional

<span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> 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

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
___

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

<i class="fal fa-hard-drive" aria-hidden="true"></i> [Add or manage Log View][]  
<i class="fal fa-square-plus" aria-hidden="true"></i> [Add or manage Log Agents][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

<i class="fal fa-search" aria-hidden="true"></i> [Log Views][]  
<i class="fal fa-box-archive" aria-hidden="true"></i> [Log Agents][]  
<i class="fal fa-rocket" aria-hidden="true"></i> [Install Mule Log Agent][Install]  
<i class="fal fa-edit" aria-hidden="true"></i> [Configuration][] of the agent  

[2]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/Mule/SessionVariable_Element.png

[Add or manage Log Agents]:https://docs.nodinite.com/administration/log-management/log-agents/features/add-or-manage-log-agent/
[Add or manage Log View]:https://docs.nodinite.com/administration/log-management/log-views/features/add-or-manage-log-view/
[Configuration]:https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/getting-started/configuration/
[Contracts]:https://docs.nodinite.com/getting-started/repository/contracts/overview/
[Custom Connector]:https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/features/custom-connector/
[CustomBusinessEvent_Configuration]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/Mule/BusinessEvent_Properties.png
[CustomBusinessEvent_Element]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/Mule/BusinessEvent_Element.png
[CustomBusinessEvent_HandlerListener]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/Mule/BusinessEvent_HandlerListener.png
[Endpoint Types]:https://docs.nodinite.com/core-services/log-event/features/endpoint-types/
[Endpoints]:https://docs.nodinite.com/repository-model/endpoints/overview/
[Install]:https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/getting-started/install/
[Integrations]:https://docs.nodinite.com/repository-model/integrations/overview/
[JavaPackage_Studio]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/Mule/JavaPackage_Studio.png
[Log Agents]:https://docs.nodinite.com/administration/log-management/log-agents/features/what-is-a-log-agent/
[Log Views]:https://docs.nodinite.com/administration/log-management/log-views/features/what-is-a-log-view/
[Message Types]:https://docs.nodinite.com/repository-model/message-types/overview/
[Mule ESB Correlation]:https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/troubleshooting/how-do-i-correlate-logged-events/
[Services]:https://docs.nodinite.com/repository-model/services/overview/
[Systems]:https://docs.nodinite.com/repository-model/systems/overview/