yiisoft/yii2

Preserve a log file's modification time on rotation

Chiusa

#20.261 aperta il 1 ott 2024

 (10 commenti) (2 reazioni) (0 assegnatari)PHP (6784 fork)batch import
help wantedstatus:ready for adoptiontype:enhancement

Metriche repository

Star
 (14.302 stelle)
Metriche merge PR
 (Merge medio 2g 15h) (47 PR mergiate in 30 g)

Descrizione

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));

Guida contributor