Mule's Tracing Module provides dedicated operations for adding values to the logging context through Mapped Diagnostic Context (MDC). A logging variable can be established once for the Mule event—for example, orderId—and that contextual information becomes available to logging performed during the event's execution.
MuleSoft specifically describes MDC as a mechanism that enriches logging and improves traceability by providing contextual information. The Tracing Module's Set logging variable operation allows application-specific identifiers to be inserted into that context. The Log4j pattern can then include MDC, avoiding the need to manually add vars.orderId to every Logger component.
Option B incorrectly assumes an ordinary Mule flow variable automatically behaves as MDC simply because Log4j configuration is modified. Option C creates repetitive and error-prone logger expressions throughout the application, directly violating maintainability objectives. Building a custom XML SDK logger wrapper is also unnecessary because Mule already provides the required tracing capability.
Using an MDC logging variable therefore centralizes the order ID as diagnostic context and allows consistent correlation across application-generated logs for the same Mule event.
Reference topics: Tracing Module; Set Logging Variable; Mapped Diagnostic Context; structured and correlated application logging.
Official documentation: https://docs.mulesoft.com/tracing-module/latest/tracing-module-logging
===============================================================