[bind10-dev] Ticket 1704 (Log output mixed)
Stephen Morris
stephen at isc.org
Tue Apr 10 13:17:07 UTC 2012
This problem manifests itself when logging is enabled to stderr (i.e.
output via cerr). When multiple processes write their messages at the
same time, the output is sometimes jumbled together,
Shane's analysis (in the ticket) is correct. The message to the console
is written in several pieces - the time, the level, the logger name etc.
cerr is not buffered, so a line of output takes several calls to
write(). If a number processes are logging to cerr, there is a
likelihood that the write() calls needed to output a single message are
interspersed with one or more write() calls from the other processes.
The problem is much reduced - if not completely eliminated - if output
is directed to stdout (i.e. output via cout). The output is buffered,
and the entire message written to the screen in one call to write() when
the line is flushed. Providing the entire message fits within the
buffer, there should be no jumbling together of messages.
The question is, what to do about it, which is why I've posted to the list:
1) The simplest solution is not to log to stderr, but to log to stdout.
The only question is whether to make logging to stdout the default.
2) Enabling buffering for cerr (as suggested on the ticket). I'm not
certain whether it is possible to add a buffer to an object that is not
expecting one (cerr might be optimised to ignore any associated
buffers). But in any case, the characteristic of cerr is that it is
unbuffered and enabling buffering might cause problems later on.
3) Finally, we can report the issue to the log4cplus maintainer and ask
that the code be altered to ensure that the message written to stderr is
written in one write call.
I suggest that we do (1) (and take the opportunity to make output to
stdout the default) and (3).
Thoughts?
Stephen
More information about the bind10-dev
mailing list