---
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 :Nodinite:. This guide shows you how to unlock powerful troubleshooting and monitoring with best practices for event correlation. :fa-link:  

<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 :Nodinite: 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].  

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

:fa-square-plus: [Add or manage Log Agents][]  
:fa-edit: [Configuration][] of the agent  
:fa-rocket: [Install Mule Log Agent][]  

## :fa-link-horizontal: Related Topics

:fa-search: [Log Views][]  
:fa-rocket: Configuring [Log4J][]  
:fa-box-archive: [Log Agents][]  

[Add or manage Log Agents]:{ndr}/Administration/1.%20Log%20Management/3.%20Log%20Agents/Features/Add%20or%20manage%20Log%20Agent.md
[Configuration]:{ndr}/Logging%20and%20Monitoring/MuleSoft%20-%20AnyPoint%20Platform%20-%20Logging/Getting%20started/3.%20Configuration.md
[Install Mule Log Agent]:{ndr}/Logging%20and%20Monitoring/MuleSoft%20-%20AnyPoint%20Platform%20-%20Logging/Getting%20started/2.%20Install.md
[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
[Log4J]:{ndr}/Logging%20and%20Monitoring/MuleSoft%20-%20AnyPoint%20Platform%20-%20Logging/Features/Log4J.md
[Mule ESB - Custom Connector]:{ndr}/Logging%20and%20Monitoring/MuleSoft%20-%20AnyPoint%20Platform%20-%20Logging/Features/Custom%20Connector.md
[SessionVariable_Element]:{ndm}/Documentation%20Pictures/LogAgent/Mule/SessionVariable_Element.png
[SessionVariable_Flow]:{ndm}/Documentation%20Pictures/LogAgent/Mule/SessionVariable_Flow.png