Boost logo

Boost :

Subject: Re: [boost] boost log to concatenate just one log file
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-01-15 09:34:27


On 1/15/19 10:41 AM, hh h via Boost wrote:
> Found out that boost::log::keywords::target = file_path caused the
> problem, removed it, all good. Not sure if it is a bug or intentional.

It is a natural known consequence of the library features not playing
well together.

The numeric suffix is added when a log file is rotated and there is a
same-named file already in the target storage, and the storage is not
the same directory where the file was written originally. To avoid name
clashes you would have to use placeholders in the filename pattern, so
that each new log file has a distinct name. If you use a counter
placeholder, you would also call scan_for_files to ensure that each run
of your application starts using a new counter value. But in that case
appending won't happen, precisely because each time you start the
application it will use a new file name. So, up until 1.70 you should
use either appending or file collecting but not both.

In 1.70 (and current develop) there is a new named parameter called
target_file_name of the backend constructor. If it is specified, the
backend will rename the log file after closing, just before passing it
to the file collector. It allows you to specify a stable name in the
file_name parameter and a mangled pattern in target_file_name, so that
name clashed don't happen in the target storage and the backend tries to
create a same named file each time. If you also disable rotation on the
backend termination, you can use both appending and file collecting.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk