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 James Hutton <ja...@gmail.com> on 2014/12/19 14:10:42 UTC

Using markers or ThreadContext to select logger via slf4j

I have some libraries that leverage slf4j for logging (can't change it)
however my application leverages log4j2 and the slf4j-log4j2 bridge.  I was
wondering if there is a way I can at the beginning of the request flow set
a value in the ThreadContext or something so that the slf4j loggers will
route to a specific log4j2 logger instead of the root logger.  Is this
possible?

Thanks,
James

Re: Using markers or ThreadContext to select logger via slf4j

Posted by James Hutton <ja...@gmail.com>.
So for example a cxf interceptor that is using slf4j internally, I'd like
to add an interceptor before it to add items to the ThreadContext that
would cause getLogger(Class) to return a different logger based upon the
value set in the ThreadContext.

On Fri, Dec 19, 2014 at 9:55 AM, Ralph Goers <ra...@dslextreme.com>
wrote:

> What do you mean by “request flow”?  You can certainly do this in your
> code.
>
> Ralph
>
> > On Dec 19, 2014, at 6:10 AM, James Hutton <ja...@gmail.com>
> wrote:
> >
> > I have some libraries that leverage slf4j for logging (can't change it)
> > however my application leverages log4j2 and the slf4j-log4j2 bridge.  I
> was
> > wondering if there is a way I can at the beginning of the request flow
> set
> > a value in the ThreadContext or something so that the slf4j loggers will
> > route to a specific log4j2 logger instead of the root logger.  Is this
> > possible?
> >
> > Thanks,
> > James
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Using markers or ThreadContext to select logger via slf4j

Posted by Ralph Goers <ra...@dslextreme.com>.
What do you mean by “request flow”?  You can certainly do this in your code.

Ralph

> On Dec 19, 2014, at 6:10 AM, James Hutton <ja...@gmail.com> wrote:
> 
> I have some libraries that leverage slf4j for logging (can't change it)
> however my application leverages log4j2 and the slf4j-log4j2 bridge.  I was
> wondering if there is a way I can at the beginning of the request flow set
> a value in the ThreadContext or something so that the slf4j loggers will
> route to a specific log4j2 logger instead of the root logger.  Is this
> possible?
> 
> Thanks,
> James


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