Details
-
Bug
-
Resolution: Fixed
-
Major
-
None
-
None
-
None
-
java 1.6.0 on Windows XP
Description
As described in http://stackoverflow.com/questions/2974857/log-back-and-thirdparty-writing-to-stdout-how-to-stop-them-getting-interleaved I've been having problems with both logback and another library both writing to System.out. Lines from the other library always appear whole, but lines from logback are sometimes broken in two by lines from the other library.
Investigating how writing to console logging works in logback I can see the root of the problem in in ConsileTarget.java.
The problem seems to be that although PrintStream.write(byte buf[], int off, int len) is synchronized, I can see in ch.qos.logback.core.joran.spi.ConsoleTarget that System.out.write(int b) is the only write method called.
So in between logback outputting each byte, the thirdparty library is managing to write a whole string to the stdout.
Patch provided: http://gist.github.com/434516
Please apply to an up coming release.
I have tested the patch in my application and can confirm that the interleaving of lines is fixed and no other side effects were observed.
David