LOG4J VERSION

1.2.6


BUG DESCRIPTION

org.apache.log4j.helpers.CountingQuietWriter says in its class comment:

  Counts the number of bytes written.

However, since its write(String) method counts it by String.length(),
current result becomes number of characters instead of byte-size.


IMPACT

CountingQuietWriter is used by RollingFileAppender to decide if rollOver()
should be called.
When multi-bytes text is written, the log file grows up over its maximum
file size specified by setMaxFileSize().


HOW TO FIX

<J2SE v 1.3.1 or earlier>
Impossible, because we cannot know which CharToByteConverter is used at all.
A better solution is to call String.getBytes().length instead of
String.length().
(still has a problem because it assumes that the text is encoded in default
 character encoding, which could be different.)

<J2SE v 1.4 or later>
Possible, if CountingQuietWriter can know which java.nio.charset.Charset
should be used. (I do not know how to get this information though.)


-------------------------------
Wataru Fukushima
PFU LIMITED


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to