Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services

Home Page:https://seldaek.github.io/monolog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeduplicationHandler always registers ::DEBUG

tomsommer opened this issue · comments

parent::__construct($handler, 0, Logger::DEBUG, $bubble, false);

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..

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.