There is currently no real default parameters for Monolog logging, and depending on environment it can lead to either no logging at all or log everything with debug level.
- When the a logger is set to an empty array [] or NULL, the resulting behaviour behaviour is to log everything to php://stderr with level debug (!). Depending on environement nothing is logged (PHP-FPM with default settings redirects stderr to /dev/null, it can be changed with the parameter catch_workers_output) or everything (Apache’s PHP module). This behaviour is because when a Monolog logger has no handler, it is forced to the stream handler php://stderr with level debug (see Logger::addRecord in Monolog 1.x, it will change with Monolog 2.0 where nothing will happen).
- If no @default key is defined, there is a PHP notice Undefined index: @default, it would be better to define one, particularly if Monolog becomes the default logging infrastructure T155552. Consequently of the point 1., in such case, Monolog uses the stream handler php://stderr with level debug.
Propositions:
- I propose that when a logger has no handler, the behaviour is to use the handler NullHandler, hence the behaviour will be consistent in all environments, and it is quite expected (I think) that if you don’t define a handler nothing is logged.
- When there is no @default key, this logger could be defined at short-term to \Monolog\Handler\StreamHandler( 'php://stderr', \Monolog\Logger::ERROR ) to avoid the level DEBUG in Apache (or any other process where stderr is not /dev/null), and perhaps in the longer-term to a specific handler logging either to $wgDebugLogFile or nowhere (to be discussed).