Issue Bug Closed

#109636RotatingFileWriter deletes all rotated files when maxFiles is 0

Ruwen Klingler 04/17/26, 19:40 updated 04/21/26, 11:30

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

History 59

  1. Gerrit Code Review pushed patch set 1 for main to change 93728 status Accepted Under Review <span data-processor="relativetime" data-value="2026-04-18T09:24:50+00:00" > 04/18/26, 09:24 </span>

  2. Andreas Kienast commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-04-18T14:35:11+00:00" > 04/18/26, 14:35 </span>

    Applied in changeset commit:a4c1fa9f3aa060a510f1f6ae32f4353e8c8eca1d.