go-dnscollector icon indicating copy to clipboard operation
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

Open lgrangeia opened this issue 2 years ago • 3 comments

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.

lgrangeia avatar Dec 09 '22 12:12 lgrangeia

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.

dmachard avatar Dec 17 '22 14:12 dmachard

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.

dmachard avatar Dec 18 '22 09:12 dmachard

Looks good to me!

lgrangeia avatar Dec 19 '22 11:12 lgrangeia