I'm using boost::log to simultaneously log to a file as well as the console. It's initialized like so:
void Init() {
logging::core::get()->set_filter
(
// set logging level to one of trace, debug, info, warning, error, fatal
logging::trivial::severity >= logging::trivial::trace
);
logging::add_common_attributes(); // enables timestamps and such
logging::add_file_log
(
keywords::file_name = logfile + "_%N.log",
keywords::rotation_size = 1024 * 1024 * 50, // 50MB log file max
// keywords::format = "[%TimeStamp%]: %Message%"
keywords::format = "%Message% #[%TimeStamp%]"
);
logging::add_console_log(std::cout,
keywords::format = "%Message%"
);
}
At certain points in my program I'd like to change the log file manually. I can change the "logfile" string in the above code and call that Init() again, but then it continues to write to the old log file and starts the new one, and starts doubling the output on the console log.
Is there some kind of corresponding "remove_file_log" I'm missing, or manually tell it to stop logging to the original log and move to the next one?