How to get Certbot to use logrotate

Here's a quick note on how to get Certbot from LetsEncrypt to use logrotate instead of its own log rotation scheme (which defaults to a staggering 1000 files).

First, you'll need a cli.ini file. Some distributions will create one for you, but if you use snapd then you'll have to create it yourself.

The line that you need is a simple:

max-log-backups = 0

That will write everything to one log file and not do the file rotation.

Then you can use logrotate as normal. Here's what I have:

/var/log/letsencrypt/*.log {
    size 100K
    rotate 7
    daily
    missingok
}

And that's it. Hope this helps someone not waste an hour trying to figure this out.


links

social