#109636RotatingFileWriter deletes all rotated files when maxFiles is 0
Description
According to documentation and changelog the RotatingFileWriter should never delete any files when the maxFiles argument is set to 0. That’s not how the RotatingFileWriter works though, as setting maxFiles to 0 actually has the opposite effect. All of the rotated log files are deleted.
Docs: https://docs.typo3.org/m/typo3/reference-coreapi/13.4/en-us/ApiOverview/Logging/Writers/Index.html#rotatingfilewriter
> This option configured how many files should be retained (use 0 to never delete any file).
TYPO3 13 Changelog: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.0/Feature-100926-IntroduceRotatingFileWriterforLogRotation.html
> maxFiles – how many files should be retained (by default 5 files, 0 never deletes any file)
> If maxFiles is configured with a value greater than 0, any exceeding log file is removed.
This is the code from TYPO3\CMS\Core\Log\Writer\RotatingFileWriter::rotate:
// Remove any excess files
$excessFiles = array_slice($rotatedLogFiles, $this->maxFiles);
foreach ($excessFiles as $excessFile) {
unlink($excessFile);
}
There is no exception for the 0 value. If maxFiles is 0, none of the rotated logs are kept. All of them are unlinked – as the name “maxFiles” suggests.
I assume this is a fault of the documentation, and not the implementation. But since the changelog page was part of the initial commit of the feature (https://review.typo3.org/c/Packages/TYPO3.CMS/+/79146) I would like to get some clarification.
I tested this in TYPO3 13. But since the code didn’t change in TYPO3 14, the issue remains there.
Reviews 2
Related issues 1
History 59
-
Ruwen Klingler changed description <span data-processor="relativetime" data-value="2026-04-17T19:43:59+00:00" > 04/17/26, 19:43 </span>
-
Andreas Kienast changed status
NewAccepted Is Regression 1 <span data-processor="relativetime" data-value="2026-04-18T09:19:37+00:00" > 04/18/26, 09:19 </span> -
Andreas Kienast changed Related to #100926 <span data-processor="relativetime" data-value="2026-04-18T09:19:50+00:00" > 04/18/26, 09:19 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 93728 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2026-04-18T09:24:50+00:00" > 04/18/26, 09:24 </span> -
Gerrit Code Review pushed patch set 2 for main to change 93728 <span data-processor="relativetime" data-value="2026-04-18T09:26:06+00:00" > 04/18/26, 09:26 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 93728 <span data-processor="relativetime" data-value="2026-04-18T09:29:24+00:00" > 04/18/26, 09:29 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 93728 <span data-processor="relativetime" data-value="2026-04-18T09:29:52+00:00" > 04/18/26, 09:29 </span>
-
Andreas Kienast commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-04-18T14:35:11+00:00" > 04/18/26, 14:35 </span> -
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2026-04-21T11:30:39+00:00" > 04/21/26, 11:30 </span>
Applied in changeset commit:a4c1fa9f3aa060a510f1f6ae32f4353e8c8eca1d.