logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: XMLSocketAppender fails
Date Wed, 12 Dec 2007 18:47:18 GMT

On Dec 12, 2007, at 7:17 AM, Mykhailo Parfeniuk wrote:

> When I use XMLSocketAppender in my application it fails with  
> assertion "invalid subscript". The reason is it tries to append zero  
> length string to output .
> When I looked at code I saw strange implementation of function write:
>
> void OutputStreamWriter::write(const LogString& str, Pool& p) {
>   if (str.length() > 0) {
>     enum { BUFSIZE = 1024 };
>     char rawbuf[BUFSIZE];
>     ByteBuffer buf(rawbuf, (size_t) BUFSIZE);
>     enc->reset();
>     LogString::const_iterator iter = str.begin();
>     while(iter != str.end()) {
>       CharsetEncoder::encode(enc, str, iter, buf);
>       buf.flip();
>       out->write(buf, p);
>       buf.clear();
>     }
>     CharsetEncoder::encode(enc, str, iter, buf);
>     enc->flush(buf);
>     buf.flip();
>     out->write(buf, p);
>   }
> }
>
> It seems to me that there should be iterator changing.
> Am I right or not?
> If use another appenders - file, console, all works normally.
> Maybe I forgot initialize something? Or function is implemented  
> incorrectly?
>
>
>

OutputStreamWriter::write is also used by all FileAppenders, so any  
flaw in its implementation would be seen there too.   
CharsetEncoder::encode() will advance the iterator as it encodes the  
string into the specified encoding.

There was recent work to make SocketAppender functional with  
Chainsaw.  I did some sanity tests with it and the SocketAppender did  
work.  However, those changes resulted in some refactoring of  
XMLSocketAppender and it is possible that I messed that up.  I didn't  
do any sanity tests with XMLSocketAppender, since I could not figure  
out how to get Chainsaw to work with it.  It would be helpful if you  
could

a) See if SocketAppender works with Chainsaw for you
b) Give me instructions on how to set up Chainsaw to work with the  
socket appender




Mime
View raw message