From 4a7fd10b05e72c9610bec9ca598161bf3b3e620d Mon Sep 17 00:00:00 2001 From: Socialpranker <273312799+Socialpranker@users.noreply.github.com> Date: Fri, 10 Jul 2026 08:58:44 +0200 Subject: [PATCH] Document -1 as the value that disables roll_keep The roll_keep docs said to set the value to 0 to disable log rotation retention limits, but modules/logging/filewriter.go treats a RollKeep of 0 as "not set" and falls back to the default of 10 (https://github.com/caddyserver/caddy/blob/master/modules/logging/filewriter.go#L258-L260). The value that actually disables the limit is -1, which lumberjack (the underlying rotator) treats as MaxBackups <= 0, meaning no limit. Reported in caddyserver/caddy#7863, where a maintainer confirmed this is a documentation bug and that the smallest compatible fix is documenting -1 as the disabling value, rather than changing filewriter.go's behavior. Fixes caddyserver/caddy#7863 --- src/docs/markdown/caddyfile/directives/log.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/markdown/caddyfile/directives/log.md b/src/docs/markdown/caddyfile/directives/log.md index 439c1a9b..1f3d16f4 100644 --- a/src/docs/markdown/caddyfile/directives/log.md +++ b/src/docs/markdown/caddyfile/directives/log.md @@ -218,7 +218,7 @@ output file { - **roll_keep** is how many log files to keep before deleting the oldest ones. Triggers when a new log file is created. - Be aware that this option and `roll_keep_for` together determine which log files are kept. For example, if log files are rotated daily, only 10 are kept based on the default `roll_keep` value of `10`, regardless of the `roll_keep_for` setting. To disable `roll_keep`, set the value to `0`. It is not recommended to set both `roll_keep` and `roll_keep_for` to `0` since all log files will be kept and likely cause the storage to fill up. + Be aware that this option and `roll_keep_for` together determine which log files are kept. For example, if log files are rotated daily, only 10 are kept based on the default `roll_keep` value of `10`, regardless of the `roll_keep_for` setting. To disable `roll_keep`, set the value to `-1`; a value of `0` is treated the same as leaving it unset and falls back to the default of `10`. It is not recommended to disable `roll_keep` together with `roll_keep_for` since all log files will be kept and likely cause the storage to fill up. Default: `10`