再コンパイルせずに重大度を調整したいので、ファイルから重大度を読み取るのにinit_from_streamを使用します。その他のオプション私はランタイムを変更する必要がないので、以前の設定はboost.log APIによって行われます。boost.log設定ファイルによる設定の重大度
設定ファイルは次のとおりです。
[Core]
DisableLogging=false
Filter="%Severity% >= 0"
コードは次のとおりです。
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
しかし、私はinit_from_stream
を追加した場合、そこにある、ファイルによってinitは「伝統的なAPIの設定」との排他的らしいました何もログアウトしない。
私の必要条件は、実行時の変更が必要なパラメータの一部を制御するためにファイルを使用することですが、すべてを必要とするわけではありません。
init_from_streamの設計目標は、現在のログの設定を変更する代わりに、ファイルからのinitログです。 – jean