---
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. :fa-bolt: :fa-search:

>[!NOTE]
>Custom Business Events are only available in **Mule ESB Enterprise Edition**

>[!TIP]
>For even more advanced features, consider using the :Nodinite: Logging [Custom Connector][] instead of Business Events.

## :fa-ballot-check: Features

* Events
  * Messages
  * Context Properties

## :fa-edit: Configuration

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

### :fa-link: 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 :Nodinite:.

![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>
```

## :fa-tags: Supported Properties

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

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
___

## :fa-hand-point-right: Next Steps

:fa-hard-drive: [Add or manage Log View][]  
:fa-square-plus: [Add or manage Log Agents][]  

## :fa-link-horizontal: Related Topics

:fa-search: [Log Views][]  
:fa-box-archive: [Log Agents][]  
:fa-rocket: [Install Mule Log Agent][Install]  
:fa-edit: [Configuration][] of the agent  

[2]:{ndm}/Documentation%20Pictures/LogAgent/Mule/SessionVariable_Element.png

[Add or manage Log Agents]:{ndr}/Administration/1.%20Log%20Management/3.%20Log%20Agents/Features/Add%20or%20manage%20Log%20Agent.md
[Add or manage Log View]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Add%20or%20Manage%20Log%20View.md
[Configuration]:{ndr}/Logging%20and%20Monitoring/MuleSoft%20-%20AnyPoint%20Platform%20-%20Logging/Getting%20started/3.%20Configuration.md
[Contracts]:{ndr}/Getting%20Started/4.%20Repository/Contracts/Overview.md
[Custom Connector]:{ndr}/Logging%20and%20Monitoring/MuleSoft%20-%20AnyPoint%20Platform%20-%20Logging/Features/Custom%20Connector.md
[CustomBusinessEvent_Configuration]:{ndm}/Documentation%20Pictures/LogAgent/Mule/BusinessEvent_Properties.png
[CustomBusinessEvent_Element]:{ndm}/Documentation%20Pictures/LogAgent/Mule/BusinessEvent_Element.png
[CustomBusinessEvent_HandlerListener]:{ndm}/Documentation%20Pictures/LogAgent/Mule/BusinessEvent_HandlerListener.png
[Endpoint Types]:{ndr}/Core%20Services/Log%20Event/Features/Endpoint%20Types.md
[Endpoints]:{ndr}/Repository%20Model/Endpoints/Overview.md
[Install]:{ndr}/Logging%20and%20Monitoring/MuleSoft%20-%20AnyPoint%20Platform%20-%20Logging/Getting%20started/2.%20Install.md
[Integrations]:{ndr}/Repository%20Model/Integrations/Overview.md
[JavaPackage_Studio]:{ndm}/Documentation%20Pictures/LogAgent/Mule/JavaPackage_Studio.png
[Log Agents]:{ndr}/Administration/1.%20Log%20Management/3.%20Log%20Agents/Features/What%20is%20a%20Log%20Agent.md
[Log Views]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/What%20is%20a%20Log%20View.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[Mule ESB Correlation]:{ndr}/Logging%20and%20Monitoring/MuleSoft%20-%20AnyPoint%20Platform%20-%20Logging/Troubleshooting/How%20do%20I%20correlate%20logged%20events.md
[Services]:{ndr}/Repository%20Model/Services/Overview.md
[Systems]:{ndr}/Repository%20Model/Systems/Overview.md