yiisoft/yii2

Preserve a log file's modification time on rotation

Closed

#20,261 opened on Oct 1, 2024

 (10 comments) (2 reactions) (0 assignees)PHP (6,784 forks)batch import
help wantedstatus:ready for adoptiontype:enhancement

Repository metrics

Stars
 (14,302 stars)
PR merge metrics
 (Avg merge 2d 15h) (47 merged PRs in 30d)

Description

What steps will reproduce the problem?

Use Yii's FileTarget enough to cause log file rotation.

What is the expected result?

FS modification time of each log file indicates the date-time when that log file was last written.

What do you get instead?

It indicates when the file was last copied in a rotation.

It is likely enough to add one line to the FileTarget::rotateByCopy() function

        @touch($newFile, filemtime($rotateFile));

Contributor guide