0

I have a BOOST_LOG_GLOBAL_LOGGER(myLogger, severity_channel_logger_mt) I created/added a console logger to this global logger within the BOOST_LOG_GLOBAL_LOGGER_INIT. how do I add a file_log that only logs records from specific channels. I have two file sinks setup, but log records end up in both files.

//in some function
shared_ptr<text_file_backend> backend = make_shared<text_file_backend>(
  keywords::filename = // provided path,
  keywords::filter = channel == "default");
shared_ptr<synchronous_sink<text_file_backend>> sink= shared_ptr<synchronous_sink<text_file_backend>>(new synchronous_sink<text_file_backend>(backend));
logging::core::get()->add_sink(sink);

//------------------

//in some other function
shared_ptr<text_file_backend> backend = make_shared<text_file_backend>(
  keywords::filename = // provided path,
  keywords::filter = channel == // provided channel);
shared_ptr<synchronous_sink<text_file_backend>> sink= shared_ptr<synchronous_sink<text_file_backend>>(new synchronous_sink<text_file_backend>(backend));
logging::core::get()->add_sink(sink);


I have tried adding another file sink with a filter to check a specific channel but it does not work .
  • Does this answer your question? [Use channel hiearchy of Boost.Log for severity and sink filtering](https://stackoverflow.com/questions/34362871/use-channel-hiearchy-of-boost-log-for-severity-and-sink-filtering) – Andrey Semashev Dec 13 '22 at 11:24

0 Answers0