I'm trying to set the boost log max_size parameter in post initialization stage. until now I was able to set it in the initialization stage like this:
logging::add_file_log(
keywords::auto_flush = true,
keywords::target =BOOST_LOG_FOLDER,
keywords::file_name =BOOST_LOG_FILE,
keywords::time_based_rotation = sinks::file::rotation_at_time_point(0,0,0),
keywords::rotation_size = 30 * 1024 * 1024,
keywords::max_size = 60 * 1024 * 1024,
);
Now I want to change the max_size after this call (according to value from input).
I don't see how this can be done
The
max_size
parameter specifies the maximum total size of the rotated files in the target directory. It is a collector parameter, so in order to change it you'll have to create and set a new collector to the file sink returned byadd_file_log
.Note, however, that the library can only decrease the limit in this way. This is because there is only one collector instance per each target directory so that the limits for the directory are universally maintained throughout the application, even if multiple sinks rotate files into the same directory.
make_collector
will verify the current limits set for a given target directory and set the most restrictive ones, which formax_size
means picking the least allowed value.