Auto‑Inject UserId and OrderId into Logs with Spring AOP and MDC
This article explains how to automatically include userId and orderId in log messages of an e‑commerce system by defining log placeholders, storing IDs in ThreadLocal, and using a custom @UserLog annotation with Spring AOP to push the values into MDC, complete with configuration, code examples, and verification steps.
