Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost logger append to file

Tags:

c++

boost

I have initialized sink that logs to file:

logging::add_file_log
            (
            keywords::file_name = "sample_%N.log",                                        /*< file name pattern >*/
            keywords::rotation_size = 10 * 1024 * 1024,                                   /*< rotate files every 10 MiB... >*/
            keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), /*< ...or at midnight >*/
            keywords::format = "[%TimeStamp%]: %Message%",                                 /*< log record format >*/
            keywords::auto_flush = true
            );

It looks it rewrites file during program restart. How to make it append to file?

like image 374
vico Avatar asked Aug 26 '14 12:08

vico


1 Answers

The documentation says

open_mode The mask that describes the open mode for the file. See std::ios_base::openmode.

The openmode keywords::open_mode for append is std::ios_base::app, so it looks like you need to add it.

like image 146
Wojtek Surowka Avatar answered Oct 05 '22 23:10

Wojtek Surowka