https://issues.apache.org/bugzilla/show_bug.cgi?id=41214

--- Comment #38 from Jess Holle <[email protected]> 2011-04-11 07:10:58 EDT ---
If we start requiring Java 5 for log4j, then there's a nice solution here for
callAppenders: use a CopyOnWriteArrayList in AppenderAttachableImpl and thus
avoid any locking when iterating over appenders.  Without Java 5 you could
implement your own CopyOnWriteArrayList, of course.

That doesn't solve some application design issues, of course -- as
AppenderSkeleton has a synchronized doAppend().  Many subclasses rely on this
locking, so it can't be blithely removed.

Removing the locking across all appenders for a given logger does eliminate
some such issues, though.  More importantly, it eliminates a key bottleneck in
log4j.  It makes sense that only one thread can write to a text file at a time.
 It makes no sense that no thread can write to a text file just because some
other thread is writing to the console (or some such), though.

Also many threads should be able to determine whether the filter is going to
reject the event, format the event going to the text file, etc, at the same
time.  The locking really should be *very* last minute.  Getting rid of the
locking at the callAppenders() level is a big step in the right direction,
though -- one which I've long since been taking by patching in an alternate
implementation of AppenderAttachableImpl that uses CopyOnWriteArrayList as
pre-Java-6 JVMs are ancient history to me at this point.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to