go-dnscollector
go-dnscollector copied to clipboard
Feature request: implement max-age for the logfile logger in order to force log rotation over a certain period of time
A common use case for the file logger is to periodically upload a compressed log file to a cloud bucket for processing.
Currently the only trigger for log rotation is the max-size / max-files. So if, for example, the log file size is under the max-size threshold, the file will not be rotated.
I propose a feature called max-age (in days or hours) such that when the log file creation date is longer than max-age, the log file will be automatically rotated.
It is difficult to get the creation date of a file on all systems. On the other hand I can easily get the last modification with Go.
Proposal to implement this feature request: add the log file date creation in the filename
- /tmp/logfile-latest-<timestamp_date_creation>.log
- /tmp/logfile.log ----> symlink ---> /tmp/logfile-latest-<timestamp_date_creation>.log
It's a way to implement rotation regarding max age and on all platforms.
Looks good to me!