Bug 38982

Summary: Add non-blocking option for AsyncAppender.
Product: Log4j - Now in Jira Reporter: Curt Arnold <carnold>
Component: AppenderAssignee: log4j-dev <log4j-dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: 1.3alpha   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: Patches to log4j 1.3 AsyncAppender to use with log4j 1.2

Description Curt Arnold 2006-03-15 15:55:29 UTC
As discussed in log4j-dev message "Contribution of non-blocking socket appender"
on 2006-01-11 (http://marc.theaimsgroup.com/?t=113700495300004&r=1&w=2), it
would be desirable to configure AsyncAppender so that logging requests made when
the buffer is full do not cause the requesting thread to block.

This feature is included in a resubstantial rewriting of AsyncAppender that will
follow which hopefully addresses the large number of deadlock reports with the
current AsyncAppender.

A new configuration "blocking" with a default value of true is added.  If set to
false, log requests received while the buffer is blocked will be used to update
a Map that is used to maintain the highest severity and count of messages for
each encountered logger.  After the messages in the buffer are output, the map
will be used to generate messages like:

org.example.foobar ERROR Discarded 15 messages due to full event buffer
including: Message from first ERROR on org.example.foobar
Comment 1 Curt Arnold 2006-03-16 05:34:48 UTC
Committed rework of AsyncAppender in rev 386266.
Comment 2 Curt Arnold 2006-03-16 06:04:12 UTC
Created attachment 17910 [details]
Patches to log4j 1.3 AsyncAppender to use with log4j 1.2

To modify a log4j 1.2 build to use the initial reworked appender.

cd src/java/org/apache/log4j
svn cat
http://svn.apache.org/repos/asf/logging/log4j/trunk/src/java/org/apache/log4j/AsyncAppender.java
> AsyncAppender.java
patch -p 5 -i AsyncAppender.patch

and build as normal.
Comment 3 Curt Arnold 2006-05-19 20:02:24 UTC
Committed new AsyncAppender to log4j 1.2 branch in rev 407896.