Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost.Log to file and stdout simultaneously?

I've used boost::log successfully to log to stdout (using the TRIVIAL macros) or to log to a file (basically following the steps in the tutorial).

How would we configure to log to a file and stdout simultaneously?

This is a common use case in our setup when we want to have both, a log file and also all the output that goes to the log on the console.

Any input appreciated!

like image 598
cacau Avatar asked Jan 27 '14 12:01

cacau


1 Answers

As per the docs you can simply use the add_console_log() convenience function like so:

#include <boost/log/utility/setup/console.hpp>

logging::add_console_log(std::cout, boost::log::keywords::format = ">> %Message%");

Of course you can always dig into the sink configuration manually as indicated by some of the comments.

like image 189
Jay Avatar answered Sep 24 '22 06:09

Jay