
... You can either create a logger and use it as an independent object, or you can declare a global logger and use it everywhere you need it. The first approach is good to store loggers as class members. The second is convenient if you tend to use functional code or don't need any context-specific attributes in it. It can be done like this:
BOOST_LOG_DECLARE_GLOBAL_LOGGER(my_logger, src::severity_logger_mt< >)
void foo() { src::severity_logger_mt< >& lg = my_logger::get(); // go ahead logging }
Hmm, I honestly think that having "loggers as class members" is a bad idea. I do not usually like global objects either (static initialization issues, too much visibility). However, what I definitely use a lot is retrieving the same log by name in different compilation modules (that takes the visibility down). Like boost::log log1(name); boost::log log2(name); // The same as log1 Best, V.