Boost logo

Boost :

Subject: Re: [boost] [log] init_from_settings - problem with applying format and filter
From: Petrovskiy Yuriy (yuriy.petrovskiy_at_[hidden])
Date: 2011-07-04 11:08:08

2011/7/4 Andrey Semashev <andrey.semashev_at_[hidden]>

> On 07/04/2011 03:47 PM, Petrovskiy Yuriy wrote:
> The questions are:
>> - How to configure severity_logger using init_from_settings() to get
>> the
>> custom severity levels in the log?
> You have to register any user-defined attribute value types with the
> library in order to be able to use it with filter and format parsers. This
> includes your severity level enum.
> If your type supports insertion and extraction from stream, you can do it
> by these two lines:
> boost::log::register_simple_formatter_factory< logMessageSeverityLevels
> >("Severity");
> boost::log::register_simple_filter_factory< logMessageSeverityLevels
> >("Severity");
> ...

Thank you, this worked good.

> - Why "Format" variables do not work? (and why %TimeStamp% starts to work
>> if using BOOST_LOG_TRIVIAL for output)?
> 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?

> - What should be done to make logger append to log (not overwrite)?
> 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.

> - Is it possible to log file and line using format variables (only to
>> file)?
> 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?

Thank you for guidance.
Yuriy Petrovskiy

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