Automatic Insertion of UserId and OrderId into Logs Using Spring AOP and MDC
This article explains how to automatically embed userId and orderId into log statements by defining log placeholders, storing these values in MDC via ThreadLocal, and using a custom @UserLog annotation together with Spring AOP to inject the data before method execution, complete with configuration and test examples.