diff --git a/src/Monolog/Handler/DoctrineProcessHandler.php b/src/Monolog/Handler/DoctrineProcessHandler.php index 07c4a0a..3ed374b 100644 --- a/src/Monolog/Handler/DoctrineProcessHandler.php +++ b/src/Monolog/Handler/DoctrineProcessHandler.php @@ -59,9 +59,7 @@ public function flush(): void } } $this->em?->flush(); - foreach ($this->records as $record) { - $this->em?->detach($record); - } + $this->em?->clear(); $this->records = new ArrayCollection(); } @@ -70,6 +68,7 @@ protected function write(LogRecord $record): void $this->records->add($record); if (500 === $this->records->count()) { $this->flush(); + $this->em?->clear(); } } }