logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Concurrency with separate logger and appender elements?
Date Fri, 25 Jan 2008 20:01:39 GMT

On Jan 25, 2008, at 8:55 AM, Ted Graham wrote:

> We are using log4j 1.2.14 as part of a financial trading system, where
> latency is important.
>
>
>
> If I have two threads logging to separate files via separate  
> appenders, can
> they execute concurrently.  If not, what is the point of contention,  
> and how
> serious is it?
>
>
>
> To explain in more detail, my config file has two <logger>s and two
> <appender>s (both DailyRollingFileAppenders).  The code references  
> one of
> the loggers by name and logs to it from a dedicated thread.  There is
> another thread that log to a variety of other loggers, which are  
> handled by
> a root level appender.  Will logging to one appender block another  
> thread
> from logging to a separate appender?
>
>
>
> Thanks,
>
> Ted
>


Unfortunately, log4j 1.2 uses coarse grain synchronization since many  
internal classes are not thread-safe.  log4j 1.2 can evaluate many  
logging requests simultaneously to see if they satisfy the threshold,  
but only one logging request at a time can be in the code that  
dispatches to the appenders.  One of the big design criteria for the  
hypothetical log4j 2.0 is to replace that coarse grain synchronization  
with a much more modern design.

Wrapping the DRFA's in AsyncAppender's should substantially reduce the  
latency issue as long as the AsyncAppender does not block (if you set  
blocking to false, if the buffer overflows a summary of the missed  
logging statements is generated).  In that case, the other threads are  
blocked only for the time necessary to add the event to the  
AsyncAppender's queue, not the time necessary to perform the IO.

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


Mime
View raw message