Java Logging with Mapped Diagnostic Context (MDC)
A Mapped Diagnostic Context (MDC) is a per-thread map of key/value pairs that a logging framework adds to log messages, so we can distinguish the interleaved log output of different requests. Log output is interleaved when a server handles multiple clients at nearly the same time. 1. Stamping Requests with MDC We use MDC to …
