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 Piotr Wielgolaski <pw...@gmail.com> on 2017/09/24 16:43:16 UTC

Asynchronous logger and thread-local appender

Hi, 
I have the case that I use appender that using thread local to fill some
context information 
https://github.com/getsentry/sentry-java/issues/508

When I understand concept of async logger and its limitation, I wonder if
there is any way to make custom appender to work with it.
I was trying to figure based on documentation some extension points, but it
sound to be huge stretch if I for example implement messagefactory or
contextinjector.

I know that I can go with async appender and it will solve the problem, but
it will kill my logging performance only for appender that should kick in
when there is exception to be sent.

Do you have any recommendation how I could make it work?
I noticed that we have asyncappnder backed by disruptor, could it be my
option?



--
Sent from: http://apache-logging.6191.n7.nabble.com/Log4j-Users-f4.html

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


Re: Asynchronous logger and thread-local appender

Posted by Remko Popma <re...@gmail.com>.
Piotr,

I agree that implementing custom Log4j2 context injector to solve this can be quite complex. 

It's a good idea to look at using AsyncAppender with an alternative queue. DisruptorBlockingQueue and JCToolsBlockingQueue are good options. 
We haven't done extensive performance analysis but initial results were promising. I don't remember exact numbers but performance was better than with ArrayBlockingQueue and close to Async Loggers in some cases. (I found some benchmarks in this JIRA ticket: https://issues.apache.org/jira/browse/LOG4J2-1430 )

That may be a fairly simple solution for your use case. 

Remko

(Shameless plug) Every java main() method deserves http://picocli.info

> On Sep 25, 2017, at 1:43, Piotr Wielgolaski <pw...@gmail.com> wrote:
> 
> Hi, 
> I have the case that I use appender that using thread local to fill some
> context information 
> https://github.com/getsentry/sentry-java/issues/508
> 
> When I understand concept of async logger and its limitation, I wonder if
> there is any way to make custom appender to work with it.
> I was trying to figure based on documentation some extension points, but it
> sound to be huge stretch if I for example implement messagefactory or
> contextinjector.
> 
> I know that I can go with async appender and it will solve the problem, but
> it will kill my logging performance only for appender that should kick in
> when there is exception to be sent.
> 
> Do you have any recommendation how I could make it work?
> I noticed that we have asyncappnder backed by disruptor, could it be my
> option?
> 
> 
> 
> --
> Sent from: http://apache-logging.6191.n7.nabble.com/Log4j-Users-f4.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>