You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Morten Sabroe Mortensen <mo...@gmail.com> on 2022/03/04 13:52:23 UTC

How to have ThreadContext be pre-populated?

I miss a handler or a mechanism to have ThreadContext be pre-populated.

Does anything exist which is called once per thread -- and without explicit
invocation by my program, of course -- ?

The values I want to pre-populate with are non-trivial and need to be read
by code; they are not constants.

-- 
Med venlig hilsen
Morten Sabroe Mortensen

Re: How to have ThreadContext be pre-populated?

Posted by Matt Sicker <bo...@gmail.com>.
That's the general purpose of the ContextDataProvider extension API.
See https://logging.apache.org/log4j/2.x/manual/extending.html#ContextDataProvider
for basic details.

On Fri, Mar 4, 2022 at 8:31 AM Gary Gregory <ga...@gmail.com> wrote:
>
> An example would help...
>
> Gary
>
> On Fri, Mar 4, 2022 at 8:52 AM Morten Sabroe Mortensen <
> morten.sabroe.mortensen@gmail.com> wrote:
>
> > I miss a handler or a mechanism to have ThreadContext be pre-populated.
> >
> > Does anything exist which is called once per thread -- and without explicit
> > invocation by my program, of course -- ?
> >
> > The values I want to pre-populate with are non-trivial and need to be read
> > by code; they are not constants.
> >
> > --
> > Med venlig hilsen
> > Morten Sabroe Mortensen
> >

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


Re: How to have ThreadContext be pre-populated?

Posted by Gary Gregory <ga...@gmail.com>.
An example would help...

Gary

On Fri, Mar 4, 2022 at 8:52 AM Morten Sabroe Mortensen <
morten.sabroe.mortensen@gmail.com> wrote:

> I miss a handler or a mechanism to have ThreadContext be pre-populated.
>
> Does anything exist which is called once per thread -- and without explicit
> invocation by my program, of course -- ?
>
> The values I want to pre-populate with are non-trivial and need to be read
> by code; they are not constants.
>
> --
> Med venlig hilsen
> Morten Sabroe Mortensen
>