This code adds an environment flag that can be used to disable or enabled context inheritance. The diagnostic contexts are stored in a thread local variable. To inhert this context between threads, we have to override the new, start, and fork methods so that we have a handle on the parent thread's context.
The unfortunate downside of this is that we end up with Logging calls in backtraces for some exceptions involving threads. This can lead to confusion.
You can set the environment variable LOGGING_INHERIT_CONTEXT to false to disable this feature if you do not need it.
This code adds an environment flag that can be used to disable or enabled context inheritance. The diagnostic contexts are stored in a thread local variable. To inhert this context between threads, we have to override the
new
,start
, andfork
methods so that we have a handle on the parent thread's context.The unfortunate downside of this is that we end up with
Logging
calls in backtraces for some exceptions involving threads. This can lead to confusion.You can set the environment variable
LOGGING_INHERIT_CONTEXT
tofalse
to disable this feature if you do not need it.fixes #155
/cc @ivoanjo