Search code examples
boostboost-log

Boost log trivial auto flush


In default mode boost.log writes to the console, which is fine by me. I'm trying to force it to auto-flush as well, however. All examples dealing with auto flush I can find show how to add a new sink, which seems unnecessary in my case. There is no method to get existing sinks via boost::log::core. Any ideas?


Solution

  • The default sink is intended to be used as a fallback of last resort and cannot be customized directly. Once you add a sink, the default sink will no longer be used. To log to the console with auto flushing enabled, one can use add_console_log.

    boost::log::add_console_log(boost::log::keywords::auto_flush = true);