You can make BOOST_LOG_TRIVIAL
use a file. Note that most of the boost::log
examples use a namespace alias as shown below.
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/utility/setup/file.hpp>
namespace logging = boost::log;
void init()
{
logging::add_file_log("sample.log");
logging::core::get()->set_filter
(
logging::trivial::severity >= logging::trivial::info
);
}
And in main:
int main(int, char*[])
{
init();
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
// other types of severity
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
return 0;
}