MDC
Learn MDC (Logging & Monitoring, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Fresher Notes MDC (Mapped Diagnostic Context) is a per-thread map of key-value pairs offered by SLF4J; the logging framework can print these values on every log line. API : MDC.put("user", "abaji") adds a value, MDC.get reads it, MDC.remove and MDC.clear delete it. Use : set request-wide data (correlation id, user, tenant) once in a filter and print it with %X{key} in the log pattern.