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 Jacob Kjome <ho...@visi.com> on 2006/02/24 04:57:23 UTC

Re: AsyncAppender revisited (was: Possible deadlock using AsyncAppender)

This seems like it would get more response on the developer list.  I 
suggest you post it there.

Jake

At 09:48 AM 2/23/2006 +0000, you wrote:
 >Log4j gurus,
 >
 >I can now confirm that I have a Log4j configuration where the dispatching
 >thread (consumer) in an AsyncAppender sometimes becomes the same as the log
 >event producer thread. This actually happens to the appender associated with
 >the root logger, hence all threads wanting to log freeze when the buffer is
 >full (the dispatching thread waits for the buffer to have available space,
 >but it's only the dispatching thread that can pop from the event queue
 >freeing up space(!)).
 >
 >I consider this a bug/weekness in AsyncAppender; it should check that the
 >calling thread is different from the dispatcher thread before pushing the
 >LoggingEvent in the append() method.
 >
 >public void append( LoggingEvent event ) {
 >       if( Thread.currentThread() == dispatcher ) {
 >               LogLog.warn( "Can't append: appending thread same as
 >dispatcher ["
 >                       + Thread.currentThread().getName() + "]" );
 >               return;
 >       }
 >       [...]
 >}
 >
 >I've written my own AsyncAppender doing the above and also refusing to log
 >if the buffer is more than 99% log and issue a warning if the buffer is more
 >than 95% full. Please find attached and use at your discretion. Thanks to
 >Elijah Baley [e_baley@hotmail.com] for ideas.
 >
 >I've also attached the log4j.xml used in a program where the said situation
 >arised - the root (async) appender's dispatcher became the same is the log
 >issues causeing all logging threads to hang.
 >
 >Swapping the native AsyncAppender with my own XAsyncAppender fixed all the
 >issues with our server.
 >
 >Any input/comments would be much appreciated.
 >
 >--
 >
 >Thomas
 >
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org


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