Opened 8 years ago

Closed 4 years ago

#1189 closed defect (duplicate)

log output to console buffering

Reported by: jreed Owned by:
Priority: low Milestone: Remaining BIND10 tickets
Component: logging Version: git
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: Low
Sub-Project: Core Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no


I was capturing stderr and stdout (tee'd into a file). After I enabled debug 100. And then did a tail of my output, no change. Then I did the dig resulting in a SERVFAIL and then my output suddenly had all the output over the past 5+ hours. Also sometimes log output wasn't complete (like no newline). So some buffering problems when outputting to stdout or stderr.

The following is from jabber:

(05:48:33) stephen: I've had a very quick look at the log4cplus code and it appears logging output to the console ultimately ends up as a standard C++ call, something along the lines of "cerr << text".

(05:49:31) stephen: So if there are problems with flushing buffers and the like, it points to a problem in the C++ library on that system. What operating system did these problems occur on?

(05:49:43) jreed: I am surprised I needed to set flush to true. Not useful default for this.

(05:49:58) jreed: This is on Debian Linux. (

(05:50:21) stephen: Hmm...

(05:50:59) stephen: AFAIK, when logging to stderr you should not have to flush after each write, it is done for you.

(05:51:34) jreed: The default is stdout.

(05:51:59) jreed: If changing that fixes it, then that is fine. But too many things to change already.

(05:52:14) stephen: Perhaps we ought to make stderr the default.


Change History (5)

comment:1 Changed 8 years ago by shane

  • Defect Severity changed from N/A to Low
  • Milestone changed from New Tasks to Next-Sprint-Proposed

For stdout, most programs do line buffering if going to a console or block buffering if going to a file. This is the default for C, C++, Python, Perl, and so on. Some programs have options to change this, for example in tcpdump:

       -l     Make  stdout  line buffered.  Useful if you want to see the data
              while capturing it.  E.g.,
              ``tcpdump  -l  |  tee     dat''     or     ``tcpdump  -l       >
              dat  &  tail  -f  dat''.

Anyway, we can ask the C++ standard output to buffer after each write, like this:

    cout << unitbuf;

You can read a bit more about it on the C++ reference page:

It's a one-line fix, but I'm not sure the right place for that one line. :)

comment:2 follow-up: Changed 8 years ago by jelte

shouldn't we leave it to the flush setting (instead of forcing a flush), and make flush default to true?

comment:3 in reply to: ↑ 2 Changed 8 years ago by jreed

Replying to jelte:

shouldn't we leave it to the flush setting (instead of forcing a flush), and make flush default to true?

This was done in #1405: [1405] Make default "flush" option for logging "true"

By default, the logging layer should now flush after each message.

Maybe this ticket can be closed.

comment:4 Changed 6 years ago by tomek

  • Milestone set to Remaining BIND10 tickets

comment:5 Changed 4 years ago by tomek

  • Resolution set to duplicate
  • Status changed from new to closed
  • Version set to git

There's #3752 in kea1.0 milestone. We plan to do it in the next couple weeks. Closing this one as duplicate.

Note: See TracTickets for help on using tickets.