logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joern Huxhorn <joern.huxh...@gmx.de>
Subject Re: [PATCH] SocketAppender-patch for the ObjectOutputStream.reset()-bug.
Date Tue, 06 May 2003 08:47:53 GMT
Hi Ray.

> Also, IMHO, Joern was trying to introduce more buffering to the 
> SocketAppender.  However, I think that a better way to implement the 
> buffering would be to chain the stream with a BufferedOutputStream or 
> to use Socket.setSendBufferSize(). 

You're right, that's exactly what I'm trying. I did, in fact, chain the 
stream with a BufferedOutputStream (bos), too. The ByteArrayOutputStream 
is in there because I first tried to
close the ObjectOutputStream to get rid of it completely which did not 
work because the ObjectInputStream would state that the stream is 
corrupted - this was generally a bad idea (my first mail, please ignore, 
I was very sleepy ;)) because it would also recreate the oos all the time.

It may be possible that the baos isn't strictly necessary but at least 
it ensures that the LoggingEvent can be serialized very fast (without 
any blocking due to buffers) which wouldn't be guaranteed if I'd just 
use a BufferedOutputStream. The buffer could be full in the middle of an 
Object and therefore block.

This code is just an idea to work around the Windows-bug mentioned in 
the javadoc. Calling LogManager.shutdown() isn't always possible (e.g in 
case of a crash where you're especially interested in the last few 
LoggingEvents or if Logging is done by means of Commons-Logging without 
hard-wiring Log4J at all) so I just tried to reduce the loss of events 
by reducing the possible blocks.

I don't think that there are any threading issues but I'm not 100% sure 
because I'm not familiar with the surrounding architecture. I think 
there are none since all I did was synchronizing all methods of 
SocketAppender that use the attribute bos. This is necessary since bos 
could be null/change and therefore isn't available for synchronization 

It sounds quite sane to me that the SocketAppender can not connect/close 
while writing an event and vice versa. That's also the reason why I 
changed line 363 which was previously synchronizing on the 
Connector-Thread instead of the SocketAppender.

Yours, Joern.

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

View raw message