A payment service stores request metadata in MDC so every log line contains the request information.
The controller logs look correct:
But every log produced inside sendReceipt() shows:
Join 8100+ developers and get weekly, no-fluff content featuring practical coding tips, real-world backend insights, and interview questions based on production scenarios.
Founding Member Offer: Lock in founding member price at $50/year (~$4/month) for life. Limited spot left.
Testimonials
Why did the audit context disappear?
Most logging frameworks store MDC using ThreadLocal. The values belong only to the current thread.
The executor picks another thread from its pool. That thread has a completely different ThreadLocal map.
Hence MDC.get("requestId") returns null
Unlike method arguments, ThreadLocal state is never copied automatically. Even if the thread comes from the same executor every time, the context is not transferred.
How would you fix it without changing every
@Asyncmethod in the application?

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.