Subject: Re: [boost] Boost::log query
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2008-09-03 15:50:38
Rajpal Dangi wrote:
> While using rotating text file as stream, is it possible to keep most
> recent log file name same all the time? Currently what I observe is 'N'
> keeps incrementing and have to manually find out the most recent file.
No, the stream always generates a new file name on rotation and uses it
to write the log to. Therefore, the mos recent log file is the one with
the last counter value.
The rationale for such behavior is that there are considerably more
possibilities for the rotation to fail, if done as you suggest. It is
possible that the current log file gets locked by another process, in
which case it is not clear where to write logs to. Also, if keeping the
current log file name the same, it would be necessary to provide at
least two file name templates to the stream: one for the current file
name and another to form up the rotated file names. This would
complicate the stream usage.
> is there some way to print severity in log file without explicitly
> passing it as part of message i.e. BOOST_LOG_SEV(my_logger, CRITICAL)
Yes, you can provide the default severity level to the logger
constructor. Having done that, all log records that are written through
this logger without an explicit severity level specification will have
the default level. For example:
severity_logger my_crit_logger(keywords::severity = CRITICAL);
BOOST_LOG(my_crit_logger) << "The record is CRITICAL by default";
<< "This record is explicitly marked as to NORMAL";
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk