mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-25 23:55:56 +03:00
[GH-ISSUE #1784] glob() not finding the existing log -> Log rotation doesn't delete files #752
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#752
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 @Defcon0 on GitHub (Dec 14, 2022).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1784
Monolog version 1|2|3? it's version 2
Related to https://github.com/Seldaek/monolog/issues/204#issuecomment-19757534
I use the drupal monolog module which is using this monolog library.
In the following line I get an empty array:
https://github.com/Seldaek/monolog/blob/2.8.0/src/Monolog/Handler/RotatingFileHandler.php#L142
for the path "private://logs/debug.log" because glob can't compute the right paths. The files definitely exist. If I replace the path with an absolute one, it works, but then I'd have to adjust the paths for each and every environment which is tedious :-/
Maybe we can think about using something else than glob() here? Or is there something I can do?
See here as well: https://www.drupal.org/project/monolog/issues/3326496
Thanks in advance!
@Seldaek commented on GitHub (Feb 4, 2023):
OK I see that glob has no support for stream wrappers, that sucks. We'd need to convert glob + getGlobPattern into something like:
computeBaseDir has to be done with caution tho, if you use something like
setFilenameFormat('{date}.log', 'Y/m/d')then you end up with$this->filenamebeing/path/to/log/2023/01/05.logso it shouldn't take the full dirname as base dir, but needs to be smarter about identifying what path is the real base path.Also would need to make sure there is no open_basedir regression regarding https://github.com/Seldaek/monolog/issues/204 as this failed with the GlobIterator previously. I'm not sure if other directory iterators have similar issues.
All in all sounds like quite a bit of work for a fairly fringe use case so I'm unlikely to spend time on this tbh. Just wrote down as much info as I could if anyone is interested in tackling this.
Otherwise I would recommend using logrotate on prod systems it's usually a better option than RotatingFileHandler IMO.