Boost logo

Boost :

From: martin.ecker_at_[hidden]
Date: 2005-06-30 02:52:50


Greg Landrum wrote:
> I'm trying to get the logs to dump their output to std:cerr immediately:
> However, the output from running this is always something like:
> 1
> 3
> [14:56:35] 2
> [14:56:35] 4
> So the logger output is "late". Is there some flag I can set (or
> appender I can use) that will force output to go to the target streams
> immediately or is this outside the design of the logging library?

I also happened to stumble accross this. The problem is that log caching
turned on initially and you have to explicitly turn it off.
Basically, it should work if you change your code to this:

int main(){
 logging::add_modifier("cerrLog",logging::prepend_time("[$hh:$mm:$ss] "),

 // now flush the log cache; this also turns off log caching, so from now
 // on all log output is not cached, but written out immediately

 std::cerr << "1" << std::endl;
 BOOST_LOG(cerrLog) << "2" << std::endl;
 std::cerr << "3" << std::endl;
 BOOST_LOG(cerrLog) << "4" << std::endl;

See the docs for more details on this.

Best Regards,

TAB Austria
Haiderstraße 40
4052 Ansfelden
Phone: +43 7229 78040-218
Fax: +43 7229 78040-209
E-mail: martin.ecker_at_[hidden]

Boost list run by bdawes at, gregod at, cpdaniel at, john at