I noticed that $wgMWLoggerDefaultSpi doesn't have any effect if I issue it at the end of my LocalSettings.php. My assumption is that the first time logging is called, global singleton stuff is set up which cannot be overwritten later. This seems fragile.
It is possible for a LoggerFactory to be initialised before LocalSettings.php is loaded, leading to the $wgMWLoggerDefaultSpi value from DefaultSettings.php being “cached” permanently. It might be a good idea to either force reset of the factory's $spi property upon loading LocalSettings.php, or to check inside getInstance() whether $wgMWLoggerDefaultSpi was changed.
Steps to reproduce
- Define $wgMWLoggerDefaultSpi in LocalSettings.php.
- Have some code emit a log message before LocalSettings.php is loaded. In my case it was the WikiSEO extension installed using composer; the autoload script uses require_once instead of wfLoadExtension(), which makes the extension emit a warning.
Logging is performed using the specified logging subsystem.
LegacySpi is used.