How are roll_keep and roll_keep_for combined?

The documentation says roll_keep defaults to 10 and roll_keep_for defaults to 2160h.

These both sets an upper limit, so how are disagreements resolved?

E.g. with default values, will I never see more than 10 log files, and never see log files older than 90 days? Or is it instead keep for at least 90 days and keep at least 10 log files?

In my case, I don’t really care about number of files, I am mostly interested in the duration, so if it is the first (never more than 10 files), is there a special value to be used with roll_keep to basically disable this check, and only go by duration?

P.S. I would suggest having the documentation use 90d as default value, instead of 2160h: In its current form, it reads like an hour value is given because d is not a supported unit in duration strings.

Caddy uses the following lib for log rolling:

roll_keep maps to MaxBackups and roll_keep_for maps to MaxAge.

They’re both maximums, but MaxAge takes precedence over MaxBackups.

Caddy actually takes a value of 0 to mean the default, so if you specify 0 for max backups, Caddy will just map it back to 10. I’m not sure what happens if you specify a value like -1 though, but it might turn the check off. You could just specify a large number of files to keep and it should likely not be a concern.

This topic was automatically closed after 30 days. New replies are no longer allowed.