Boost logo

Boost :

Subject: Re: [boost] [log] init_from_settings - problem with applying format and filter
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2011-07-04 13:53:58

On 07/04/2011 07:08 PM, Petrovskiy Yuriy wrote:
>> Because you didn't add the TimeStamp attribute to the core. Your log
>> records don't contain time stamps and thus you don't see them in the output.
> How to add it correctly?

There is an example:


If you're using Boost.Log from SVN trunk, replace boost::make_shared<
attrs::local_clock >() with attrs::local_clock().

>> You should specify open_mode parameter when creating the text file sink,
>> like this:
>> init_log_to_file(
>> keywords::file_name = "my.log",
>> keywords::open_mode = std::ios::app);
>> You can also pass this option to the backend constructor, if you create it
>> explicitly.
> Is it possible to do with init_from_settings? I found no corresponding
> option in documentation. I think it is important feature to be configured
> through config file|settings.

No, there isn't one. The motivation was that this property is usually
programmer-defined, not user-defined, and thus it should not be exposed
in the config file.

You can, however, achieve this functionality through config file by
registering your own sink factory. This factory can create the standard
text file sink, only with the required options. There is an example:


>> You mean file and line where a log record is made? You can do this, but
>> only if you add file name and line number as attributes to each record. You
>> can wrap in the logging macros to do this automatically.
> Is there any standard solution for this?

No, not out of the box. You could use constant attribute and scoped
attributes to achieve that.



Boost list run by bdawes at, gregod at, cpdaniel at, john at