Do you realize that the main reason for synchronization in doAppend method is avoiding simultaneous writes to the same output device? Any write operation which is not synchronized (or otherwise protected against simultaneous access) is a big no no...
At 08:35 PM 9/17/2004, Elias Ross wrote:
On Fri, 2004-09-17 at 10:40, Ceki Gülcü wrote:
> Elias,
>
> How are your changes compatible with log4j 1.3 where layouts write directly
> to the output stream without intermediary String objects?
It would seem the same issue would occur if an appender is locked when a layout is writing directly to the output stream.
Fundamentally, the changes would be the same.
* Remove synchronization from AppenderSkeleton during doAppend (Possibly create a related class as the locking strategy is now different.) * subAppend would be changed as follows:
src/java/org/apache/log4j/WriterAppender.java
protected void subAppend(LoggingEvent event) { Layout l = this.layout; if (l == null) { errorHandler.error( "No layout set for the appender named [" + name + "]."); return; } Writer w = this.qw; if (w == null) return; try { l.formatAndWriteEvent(w, event); if (this.immediateFlush) { this.qw.flush(); } } catch (IOException e) { errorHandler.error("....") }
}
The only catch is if the threshold is being lowered when an event is going off. What will then happen is the event will be logged anyway.
If the write is closed during the event, then potentially only half the stack trace will be logged if the writer is not locked.
If this is a concern, you might want to create some sort of semaphore so that when an event is being logged, the appender state can't be affected. However, as many concurrent events can be logged at the same time.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Ceki G�lc�
For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
