mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #1905] $mustRotate in RotatingFileHandler not resetting properly #818
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#818
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @khoanguyen-3fc on GitHub (Aug 6, 2024).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1905
Our team is using Monolog version 2 and has encountered an issue where the
$mustRotateattribute of theRotatingFileHandleris only set tofalseif all unrelated conditions in therotatemethod are satisfied:github.com/Seldaek/monolog@884aa47a05/src/Monolog/Handler/RotatingFileHandler.php (L128-L171)This issue interacts with Octane, leading to a serious problem where logs cannot rotate to a new file. The problem arises because the
resetmethod is called on everyRequestReceived:https://github.com/laravel/octane/blob/2.x/src/Listeners/FlushMonologState.php
When a
RotatingFileHandlerinstance is reset withtrue === $this->mustRotate, the$this->urland$this->nextRotationattributes are updated by callingrotate:github.com/Seldaek/monolog@884aa47a05/src/Monolog/Handler/RotatingFileHandler.php (L133-L135)As a result, the
writemethod cannot write to the new stream because$this->close()is never reached. This occurs because$this->nextRotationis already updated during the call toreset:github.com/Seldaek/monolog@884aa47a05/src/Monolog/Handler/RotatingFileHandler.php (L113-L126)