Manual talk:MonologSpi.php

Jump to navigation Jump to search

Minimal example?[edit]

It would be really helpful to explain the defaults, and give an example configuration that overrides as little as possible. The maximal cases are covered here, but it's generally bad practice to unnecessarily override defaults, because your configuration will break as those defaults change.

Adamw (talk) 19:30, 10 August 2015 (UTC)

Yes Done @Adamw: I’ve added a minimal useful example. It’s still fairly long because, as far as I can tell from the MonologSpi code, there are no defaults, so even a simple line formatter has to be configured explicitly. --Lucas Werkmeister (WMDE) (talk) 12:46, 21 July 2017 (UTC)
Another thing useful is a small note explaining how the log reaches LogStash (or a pointer to such a note), for example a schema log → redis → <some observer component> → ElasticSearch → LogStash. --Dereckson (talk) 23:54, 21 March 2018 (UTC)
There is a slightly out of date, but mostly correct, explanation of the Wikimedia production cluster configuration at wikitech:Logstash. The current configuration uses the MediaWiki\Logger\Monolog\SyslogHandler to send debug log events to Logstash. The log events are processed by various Logstash modules and then finally stored in an Elasticsearch cluster. The data from that cluster is searchable using a Kibana instance. This data pipeline is not the only way that MediaWiki debug log events could be fed into Elasticsearch, but it is one with working (but complicated) examples. --BDavis (WMF) (talk) 03:21, 22 March 2018 (UTC)
As of monolog 1.25.2 (the version on master as of git sha e41bc16e3164c3b1db2e875c2ce11d9224a0ba0f), the minimal example config no longer works. It fails with
PHP Fatal error:  Uncaught Error: Call to undefined method Monolog\Utils::jsonEncode() in /var/lib/mediawiki/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php:174
Stack trace:
#0 /var/lib/mediawiki/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php(163): Monolog\Formatter\NormalizerFormatter->toJson(Array, true)
#1 /var/lib/mediawiki/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php(127): Monolog\Formatter\LineFormatter->convertToString(Array)
#2 /var/lib/mediawiki/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php(103): Monolog\Formatter\LineFormatter->stringify(Array)
#3 /var/lib/mediawiki/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Formatter\LineFormatter->format(Array)
#4 /var/lib/mediawiki/vendor/monolog/monolog/src/Monolog/Logger.php(344): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#5 /var/lib/mediawiki/vendor/monolog/monolog/src/Monolog/Logger.php(628): Monolog\Logger->addRecord(100, 'MainObjectStash...', Arra in /var/lib/mediawiki/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php on line 174
SSastry (WMF) (talk) 06:00, 6 January 2020 (UTC)

How to not log[edit]

Would be helpful to give an example where @default is redirected to null and only specific channels are logged. Nikerabbit (talk) 15:06, 1 November 2018 (UTC)