quill
quill copied to clipboard
TimeRotatingFileHandler doesn't rotate when constructed
Previously used the DailyFileHandler, recently updated to TimeRotatingFileHandler but notice that our logs no longer rotate.
The application does not run 24/7 but we wanted to store the last 14 days of logs, the previous file handler would create a log file and name it based on the current day. The new one just seems to make a log file with the base name and then not rotate unless its active.
This would essentially render it useless for us in a lot of cases as we will have to manually name our logs per day, and check them ourselves to see if they need to be deleted.
If its intended to run 24/7 then that should be made clearer in the documentation. However it would be nice if when logs were created it also ran the same rotation checks.
Hey, thanks for reporting.
Yes the new TimeRotatingFileHandler
does create a log file with a base name.
I will have a look and probably improve this to also rotate on construction.
Quill is designed so that handlers
are easily expandable, meaning that anyone can add his own custom handler.
As a workaround for now I would suggest that you can still use the latest version of quill with the old DailyFileHandler
.
The code for the old DailyFileHandler
is here:
https://github.com/odygrd/quill/blob/v1.3.3/quill/include/quill/handlers/DailyFileHandler.h https://github.com/odygrd/quill/blob/v1.3.3/quill/src/handlers/DailyFileHandler.cpp
You can manually add those 2 files in your project and then just include and construct the old DailyFileHandler
as you used to do in the older version and it should work.
If you have any issues please let me know.
I am closing this since it is now possible to create a TimeRotatingFileHandler that includes the start time of the application e.g.
std::shared_ptr<quill::Handler> file_handler =
quill::time_rotating_file_handler(base_filename, "w", quill::FilenameAppend::DateTime, "M", 1);
std::shared_ptr<quill::Handler> file_handler =
quill::time_rotating_file_handler(base_filename, "w", quill::FilenameAppend::Date, "M", 1);