I am facing an issue with file rotation using Boost logging::add_file_log.
The sink setup uses the following settings. Just listing those here. They are keywords::file_name, keywords::target, keywords::rotation_size, keywords::max_size, keywords::max_files, keywords::auto_flush, keywords::scan_method.
File Rotation Working Flow in Normal scenario (when application does not crash): A new file gets created when the size of the current file exceeds 10 MB. The application will start writing a new file and when it reaches rotation_size, it will get rotated. If at this point, the total size of files in the storage exceeds max_size, older files will be deleted so that max_size is satisfied.
File Rotation Working Flow in Crash scenario: In case of an app crash, the rotation size is never hit, hence the check for max size does not happen, therefore the file rotation does not occur in crash scenarios.
Therefore on a machine running this application, which is continuously crashing, it is validated that even if the total size (sum of sizes of files in target folder) exceeds the MAX_SIZE, the older files don't get deleted.
The crash may happen in this application due to external factors as well like machine reboots & there would be many machines running this application. Also, if the folder size has exceeded the max size, a new version of the application needs to be deployed, its new log file needs to reach the limit, and only then the older files would be deleted which is a problem.
The usable disk size limit is hardbound in my case, due to this issue if the size exceeds the limit, there are other implications.
This is a valid scenario to cover. Hence fixing the crash does not fit in for the ask here.
How can we solve this using boost?
Thanks.
Aucun commentaire:
Enregistrer un commentaire