mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-25 23:55:56 +03:00
[GH-ISSUE #2011] StreamHandler doesn't handle non-blocking streams properly, truncating logs #861
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#861
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 @martin-heralecky on GitHub (Dec 22, 2025).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/2011
When writing large logs to a non-blocking stream, logs are often truncated. The exact length of the line that is actually written varies between calls.
Here's a snippet that attempts to write around 1M characters to a non-blocking stream:
Run with
php snippet.php | wc -cto see the number of characters actually written. On my platform, this is typically around 64K. I'm using monolog version 3.9.0.The problem lies in the
StreamHandler::streamWrite()method, which ignores the return value offwrite(). I believe the correct solution is to callfwrite()in a loop until all characters are written. If it is desirable to have this behavior in monolog, I am willing to put together a patch.@Seldaek commented on GitHub (Dec 30, 2025):
Yeah that sounds very reasonable, definitely should be fixed.