Hi,
I’m using Consul version 1.8.4 and am trying to configure the managed log rotation.
I have included the log_rotate_max_files parameter in my local.json file, but log files continue to pile up with each restart. I also tried -1 which should delete all except the most recent.
I can confirm that the file is being read, because if I put a bad value (i.e: “log_rotate_max_files”: a), the service will not start.
Thanks
Hello, thanks for the question!
It looks like the log_rotate_max_files
setting is only used when a rotation happens. File rotation can happen either when the number of bytes in the current file exceeds log_rotate_bytes
or when the current file has been used for longer than log_rotate_duration
.
It looks like if neither of those values are set the file will never be rotated. Unfortunately it does not try to rotate when consul starts, so if you are restarting Consul frequently before one of those thresholds is hit, it also will not rotate.
It may be possible to have pruning run on startup as well, if we make a code change.
I hope this helps!
Edit: I opened https://github.com/hashicorp/consul/pull/9012 to prune logs on startup