-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve a log file's modification time on rotation #20261
Comments
Is there a big difference? Why does it matter? |
Why do we even use |
Difference can be big. Say you have a log that rotates approx. every month and you keep 5. If when you go to look at the logs the rotation happened an hour ago, all 5 files have an mtime of one hour ago.
It matters because the correct mtime tells you when a file was last written. So if you want to look at logs surrounding a given timestamp, you can choose the file to look at from |
Good question. I guess it's because the code to copy the active file and rename the older ones would be more complex and nobody got around to writing it. |
I can code this but I have no idea how to write the tests for it. |
Yeah. Time-based tests that include file system are tricky. |
JFTR: The option to use rotateByRename has been removed here: #19259 |
@spinitron is the issue still valid considering copy() was removed? |
Right! |
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
The text was updated successfully, but these errors were encountered: