Peter Podniesinski created LOG4J2-2855:
------------------------------------------
Summary: Managing ThreadContext across thread pool and worker
threads
Key: LOG4J2-2855
URL: https://issues.apache.org/jira/browse/LOG4J2-2855
Project: Log4j 2
Issue Type: Question
Components: API
Affects Versions: 2.10.0
Reporter: Peter Podniesinski
Hello, my team supports a spring boot rest API and we have been leveraging
_ThreadContext_ to share meta-data about our api requests to the log events we
record throughout our request processing.
Recently we had noticed that logs generated from thread-pool or worker threads
*do not* share this context and the contextMap would be empty.
For that reason we enabled
{code:java}
isThreadContextMapInheritable=true
{code}
This indeed shares the context to child threads, but now we are having an issue
where the contextMap is bleeding into the logs of other API requests. Please
advise how to better tune this functionality.
Below is a snippet of code where we build the ThreadContext in the API resource
and attempt to clear it before another request comes in.
{code:java}
try {
ThreadContext.put("id", request.getId());
<..more context..>
return evaluate(request
} finally { ThreadContext.clearAll(); }
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)