I am trying to use a Mapped Diagnostic Context to add the username of the user making a page request to all relevant logging statements. However I have tried three different ways to make it work without success:
- Pushing the username into the MDC after login and removing after logout. This method ends up mixing up which logging statement came from which user.
- Using a ServletFilter to push the username into the MDC on each page load and pop it back off as the request ends. This only catches some of the data and only in Spring security layer.
- Using a AOP @Around interceptor in front of all the Controller methods flat out didn't work.
Does anyone have any suggestions on how to make this happen?