Async logging will not cause messages to appear out of order in the log file. 

Please take a look at the performance page 
(https://logging.apache.org/log4j/2.x/performance.html). Async logging is fast 
because of reduced lock contention. Lock contention happens when you have many 
threads logging simultaneously. If your application doesn’t do that, benefits 
will be limited. 

The 10% speedup you mentioned indicates to me that logging is not the main 
performance bottleneck (at least during the tests). 

It’s a nice gain for little effort, but if your aim is to dramatically improve 
the performance of your application, it’s best to first approach this 
systematically: identify the biggest bottleneck, optimize that, measure again, 
etc. 

Remko
 

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

> On Aug 8, 2018, at 0:47, Shawn Heisey <apa...@elyograg.org> wrote:
> 
>> On 8/6/2018 4:35 PM, Remko Popma wrote:
>> If you have multiple threads that log quite a lot, async logging can make a
>> big difference.
>> If you don't log much, or if the logging is mostly happening on a single
>> thread, I'd suggest sticking with synchronous logging for its simplicity.
> 
> Solr is a fully threaded application that runs in a servlet container.  In 
> busy environments, there will be many things happening simultaneously that 
> will all generate logs.  I would call what Solr generates a sort of "medium" 
> level of logging. There's a fair amount of detail when request happen, but 
> when there are no requests, most Solr installs will not be logging anything 
> unless Jetty has something to say.
> 
> Did you see my question early in the thread about whether async logging can 
> place entries in the log that are out of sequence, and whether that could be 
> helped by using sync logging for WARN and above, with lower levels using 
> async?  One thing I'm going to keep in my tech support hat after we complete 
> the switch to async is having users change the logging back to sync if 
> there's any concern about timing of log entries.  That should probably end up 
> in Solr documentation as well.
> 
>> Have you thought of any way to measure the performance difference between
>> synchronous and async logging for your application? (If you cannot tell the
>> difference, then what's the point?) :-)
> 
> In SOLR-12055, one of my fellow committers did a Solr test run (running "ant 
> test") that took 42 minutes.  Then Root was changed to AsyncRoot, and the 
> next test run only took 38 minutes. The Lucene project has some automated 
> benchmarks, work is underway to bring something similar to Solr.  The idea 
> will be to put Solr through a workload that's similar to something that might 
> happen in a real install.
> 
> My personal goal in switching to async is achieving the "insane performance" 
> I've heard about that upgrading from log4j1 to log4j2 makes possible.  
> Definitely hoping we won't see any downsides.
> 
>> If you decide it is worth it, you can switch by changing Root to AsyncRoot
>> and Logger to AsyncLogger in your configuration.
> 
> Thank you for that information. I think the async page in the log4j 
> documentation should have a paragraph near the beginning about switching 
> existing configs to async, with that simple statement in it.
> 
> Thanks,
> Shawn
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 

Reply via email to