---
title: How to Correlate Logged Events in Mule ESB Flows with Nodinite
description: Master event correlation in Mule ESB flows using session variables and Nodinite. Learn best practices for seamless end-to-end tracking, troubleshooting, and business insight.
---

# How do I correlate logged events?

>Achieve seamless end-to-end tracking and business insight by correlating all logged events within a Mule ESB flow using <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>. This guide shows you how to unlock powerful troubleshooting and monitoring with best practices for event correlation. <i class="fal fa-link" aria-hidden="true"></i>  

<div class="mermaid">
graph LR
    subgraph "Mule ESB Flow - Correlation"
        ro[Init Session Variable</br>RunId=123] --> | Do stuff | roE1(fal:fa-bolt Log Event</br>RunId=123)  
        roE1 --> | Do stuff | roE2(fal:fa-bolt Log Event</br>RunId=123)  
        roE1 --> | Do stuff | roE3(fal:fa-bolt Log Event</br>RunId=123)  
    end
</div>

*Illustration: All log events in a Mule ESB flow share the same RunId for correlation.*  

To correlate multiple messages within the same Mule Flow, you must use a **session variable**. This approach ensures every log event in a single run is uniquely linked, enabling advanced analytics and troubleshooting.  

![SessionVariable_Element][SessionVariable_Element]  
*Session variable element in Mule ESB*  

Set the session variable, typically named `RunID`, before the first logging point in your flow. This guarantees all subsequent log events share the same correlation ID.  

![SessionVariable_Flow][SessionVariable_Flow]  
*Session variable placement in the Mule ESB flow*  

```xml
<set-session-variable variableName="runID" value="# [java.util.UUID.randomUUID().toString()]" doc:name="Session Variable"/>
```

## Log using Nodinite Logging Custom Connector

When using the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Logging Custom Connector, provide the session variable `RunID` as the **local interchange id** property when calling the Log sub flow with the [Mule ESB - Custom Connector][]. This ensures all related events are grouped for easy tracking and analysis.  

## Log using Log4J

The Mule [Log Agent][Add or manage Log Agents] leverages the **Log4J** framework to capture and forward log messages. For optimal correlation, configure Log4J within your Mule ESB flows as described in the [Log4J configuration guide][Log4J].  

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

<i class="fal fa-square-plus" aria-hidden="true"></i> [Add or manage Log Agents][]  
<i class="fal fa-edit" aria-hidden="true"></i> [Configuration][] of the agent  
<i class="fal fa-rocket" aria-hidden="true"></i> [Install Mule Log Agent][]  

## <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-rocket" aria-hidden="true"></i> Configuring [Log4J][]  
<i class="fal fa-box-archive" aria-hidden="true"></i> [Log Agents][]  

[Add or manage Log Agents]:https://docs.nodinite.com/administration/log-management/log-agents/features/add-or-manage-log-agent/
[Configuration]:https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/getting-started/configuration/
[Install Mule Log Agent]:https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/getting-started/install/
[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/
[Log4J]:https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/features/log4j/
[Mule ESB - Custom Connector]:https://docs.nodinite.com/logging-and-monitoring/mulesoft-anypoint-platform-logging/features/custom-connector/
[SessionVariable_Element]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/Mule/SessionVariable_Element.png
[SessionVariable_Flow]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/Mule/SessionVariable_Flow.png