Re: Need to clear ThreadContext for each HTTP request?

2018-04-18 Thread Kevin Jung
Agreed. I don't think we need a separate filter from log4j2. People may already have filters and just need to add one line there; or can create one easily if they don't have. But I think it's good to mention somewhere, probably on https://logging.apache.org/log4j/2.x/manual/thread-context.html t

Re: Need to clear ThreadContext for each HTTP request?

2018-04-18 Thread Remko Popma
This is not something that can or should be automated imho. ThreadContext data disappearing automatically can be just as confusing to troubleshoot (or more so). Remko > On Apr 19, 2018, at 2:40, Gary Gregory wrote: > > On Tue, Apr 17, 2018 at 10:22 AM, Ralph Goers > wrote: > >> I have mixe

Re: Need to clear ThreadContext for each HTTP request?

2018-04-18 Thread Gary Gregory
On Tue, Apr 17, 2018 at 10:22 AM, Ralph Goers wrote: > I have mixed feelings about that. Every filter I have created that clears > the ThreadContext at the end also injects values into the ThreadContext at > the beginning of the request, just as the example at > http://logging.apache.org/log4j/2.

Re: Need to clear ThreadContext for each HTTP request?

2018-04-17 Thread Ralph Goers
I have mixed feelings about that. Every filter I have created that clears the ThreadContext at the end also injects values into the ThreadContext at the beginning of the request, just as the example at http://logging.apache.org/log4j/2.x/manual/eventlogging.html

Re: Need to clear ThreadContext for each HTTP request?

2018-04-17 Thread Gary Gregory
Should we provide a stock Log4j filter that does that? A nice convenience. Gary On Mon, Apr 16, 2018 at 10:01 PM, Kevin Jung wrote: > Thanks Remko and Ralph for the information. I thought of clearing in a > filter, but somehow I thought there might be a clean up mechanism already > because usi

Re: Need to clear ThreadContext for each HTTP request?

2018-04-16 Thread Kevin Jung
Thanks Remko and Ralph for the information. I thought of clearing in a filter, but somehow I thought there might be a clean up mechanism already because using ThreadContext in Tomcat is a quite common thing. But that was just my assumption. I agree that it's better to *clear explicitly*. Thanks

Re: Need to clear ThreadContext for each HTTP request?

2018-04-16 Thread Ralph Goers
See the example at http://logging.apache.org/log4j/2.x/manual/eventlogging.html . You will see the call to clear the ThreadContext. It does indeed use a filter. Ralph > On Apr 16, 2018, at 7:01 PM, Kevin Jung wrote: > > Hello, > >

Re: Need to clear ThreadContext for each HTTP request?

2018-04-16 Thread Remko Popma
Very good question. Please be aware that Log4j will *not* clear the ThreadContext. Your concern that ThreadContext values may become visible to other threads because of Tomcat’s thread pool is a legitimate concern. It is a good idea to explicitly clear values when the application is done with

Need to clear ThreadContext for each HTTP request?

2018-04-16 Thread Kevin Jung
Hello, I am using Log4j 2 ThreadContext with Tomcat. I wonder if I need to clear ThreadContext at the end (or start) of HTTP request in order to avoid the context data being carried over to next HTTP request processing. I was assuming that thread context is cleared when Tomcat thread is put back