You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
Defcon0
changed the title
https://github.com/Seldaek/monolog/issues/204#issuecomment-19757534
glob() not finding the existing log -> Log rotation doesn't delete files
Dec 14, 2022
OK I see that glob has no support for stream wrappers, that sucks. We'd need to convert glob + getGlobPattern into something like:
$baseDir = $this->computeBaseDir($this->filename);
$directory = new RecursiveDirectoryIterator($baseDir);
$iterator = new RecursiveIteratorIterator($directory);
$regex = new RegexIterator($iterator, $globPattern);
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->filename being /path/to/log/2023/01/05.log so 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 #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.
Monolog version 1|2|3? it's version 2
Related to #204 (comment)
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!
The text was updated successfully, but these errors were encountered: