DeduplicationHandler always registers ::DEBUG
tomsommer opened this issue · comments
The DeduplicationHandler always registers Logger::DEBUG
, it should be $deduplicationLevel
because otherwise all DEBUG data is logged to the dedup file and parsed for dedup, leading to unintentional memory issues and logging.
The point is that it wants to catch all logs to forward everything to the nested handler, but in flush() only records with a higher level than $deduplicationLevel are actually looked at and logged to the dedup file, so it seems fine to me?
If you are really logging lots and are worried about memory issues (if you are running long processes, don't forget to call $logger->reset() between every job to make sure to clear buffers), worst case you could wrap the DeduplicationHandler in a FilterHandler or BufferHandler to filter out what reaches it..
BTW added docs about reset which I just realized were missing.. https://github.com/Seldaek/monolog/blob/main/doc/01-usage.md#long-running-processes-and-avoiding-memory-leaks
Actually, this was a long-running script with lots of debug data, which suddenly consumed several GB of memory (and was killed by oom-killer) because this DEBUG data was being stored.
At the very least I would say the level should be configurable.
Well you can call $handler->setLevel()
to override this if you must, but I'd rather recommend making use of reset() to properly handle long running scripts.