What is a best practice to enrich every log message with the order ID?

A Mule application for processing orders must log the order ID for every log message output.

What is a best practice to enrich every log message with the order ID?
A . Use flow variables within every logger processor to log the order ID
B . Set a flow variable and edit the log4/2.xml file to output the variable as part of the message pattern
C . Create a custom XML SDK component to wrap the logger processor and automatically add the order ID within the connector
D . Use the Tracing module to set logging variables with a Mapped Diagnostic Context

Answer: D

Explanation:

To enrich every log message with the order ID, the developer should use the Tracing module to set logging variables with a Mapped Diagnostic Context (MDC). The Tracing module allows adding custom key-value pairs to log messages using MDC variables. The developer can use Set Logging Variables operation to set the order ID as an MDC variable and then use it in any logger processor within the same thread or event.

References: https://docs.mulesoft.com/tracing-module/1.0/tracing-module-reference#set-logging-variables

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments