a way to disable Monolog on a per-script basis?

monolog, php, symfony

Solution

I realise this is an old question, but when I ran into problems with a long-running, Monolog-using script generating out of memory errors, it turned out the problem was Monolog's 'fingers_crossed' handler buffering a ton of log messages.

I solved the problem by setting the 'buffer_size' variable for the Monolog handler in question. Something like this:

main:
    type:         fingers_crossed
    action_level: info
    buffer_size:  200
    handler:      nested

Edit: As pointed out by Sergio in the comments, `buffer_size` sets: 'How many entries should be buffered at most, beyond that the oldest items are removed from the buffer'.

Problem

we have some rather large data-import scripts (Symfony "Commands") which are erroring out due to Monolog running out of memory (vendor\monolog\src\Monolog\Formatter\LineFormatter.php on line 58). we use Monolog in general, so would not like to disable it entirely.

Original source