You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2014/01/03 03:17:50 UTC

[jira] [Commented] (LOG4J2-479) Use of InheritableThreadLocal in Map ThreadContext is dangerous and unhelpful

    [ https://issues.apache.org/jira/browse/LOG4J2-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13861104#comment-13861104 ] 

Remko Popma commented on LOG4J2-479:
------------------------------------

Can you confirm the desired behaviour? In the scenario you described:

user1 logs in, (any logging in the web request handler thread should use this user's ThreadContext info), 
user1 thread submits a batch job request, threadExecutor launches a new thread which does not inherit any thread context, and 
any logging in thread pool thread should take place without any thread context info.

Is this what you are trying to achieve?

One way to accomplish this is to call ThreadContext.clear() at the start of any batch job Runnable or Callable that is submitted to the thread pool. Would that solve the issue? 

> Use of InheritableThreadLocal in Map ThreadContext is dangerous and unhelpful
> -----------------------------------------------------------------------------
>
>                 Key: LOG4J2-479
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-479
>             Project: Log4j 2
>          Issue Type: Bug
>            Reporter: MK
>
> Described here http://logging.apache.org/log4j/2.x/manual/thread-context.html
> The use of InheritableThreadLocal creates subtle and hard to track bugs while not really adding much useful.  It is counterintuitive -- I don't see why would anyone expect logging context to be inherited.  But it breaks down completely when used with Thread Executors.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org