I have a Spring MVC app that has logging set up using SLF4J. I am using two different aspects (using spring-aop) to do the logging, one to log all incoming http requests, and another to log asynchronous tasks. The asynchronous tasks are launched using an ExecutorService.
My understanding was that when you use an ExecutorService, the spawned thread's MDC will not inherit values already set. But it seems it does. Fair enough. I just call org.slf4j.MDC.clear() in my child thread to reset the values.
My problem is that values I am setting in the spawned child thread are also showing up in the original parent thread's MDC.
Is this normal, or am I doing something wrong? Is there any way to prevent this?