diff --git a/src/Monolog/Handler/StreamHandler.php b/src/Monolog/Handler/StreamHandler.php index e1258270..6153cc28 100644 --- a/src/Monolog/Handler/StreamHandler.php +++ b/src/Monolog/Handler/StreamHandler.php @@ -79,6 +79,20 @@ class StreamHandler extends AbstractProcessingHandler $this->useLocking = $useLocking; } + /** + * @inheritDoc + */ + public function reset(): void + { + parent::reset(); + + // auto-close on reset to make sure we periodically close the file in long running processes + // as long as they correctly call reset() between jobs + if ($this->url !== null && $this->url !== 'php://memory') { + $this->close(); + } + } + /** * @inheritDoc */