I want adjust severity level without recompile, so I use init_from_stream to read severity level from file. Other options I don't need change runtime, so their setting as before is done by boost.log API.
The config file is:
[Core]
DisableLogging=false
Filter="%Severity% >= 0"
The code is:
std::ifstream file("log_setting.ini");
boost::log::init_from_stream(file);
boost::log::register_simple_formatter_factory< severity_level, char >("Severity");
// following is same as before(all setting is by calling API, and comment out severity settings)
boost::shared_ptr<boost::log::core> core = boost::log::core::get();
core->set_exception_handler(boost::log::make_exception_suppressor());
//add and set sinks
But I found the init by file seems exclusive with "traditional API setting", if I add init_from_stream
, there is nothing log out.
My requirement is use setting file to control some parts of parameters which I need change runtime but no all of them.