Boost logo

Boost Users :

Subject: Re: [Boost-users] [log] connecting a logger to a specific sink
From: Igor R (boost.lists_at_[hidden])
Date: 2013-12-04 08:25:18

> I think you need to read the attribute page in details but you mostly get it apparently.
> Basically, you don't associate attribute to loggers but to log record.
> In your case I think the simplest way would be to have a different logging macro (or function),
> that would do the log record setup and send manually but will add necessary attributes in the middle.

That's the approach I'd like to avoid, due to some legacy code
limitations (I'm moving to Boost.Log from some other logger).
But it turns out that it's possible to attach attributes to loggers in
a straightforward way:
BOOST_LOG_ATTRIBUTE_KEYWORD(my_attr, "my_attr", int)
logger->add_attribute("my_attr", attrs::constant<int>(i));

It works as I expected and solves my problem.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at