Manual:MonologSpi.php

is a service provider interface for use with  that creates Monolog loggers. MonologSpi enables Structured logging, which means you can record an arbitrary array of data with your log events instead of just a string.

Requirements
requires Monolog to be installed and available to your wiki. One way to do this is with Composer, by adding the following to your  and running.

Details
Monolog allows a large amount of flexibility in configuring the destination, format and contents of log events. The basic building blocks of a Monolog configuration are:


 * Loggers
 * A logger is a named logging channel. The name of the channel is used to determine what configuration to apply to messages sent to that channel.


 * Processors
 * A processor adds or modifies contextual information of a log event.
 * Including the  handler is recommended to make Monolog expand PSR-3   placeholders in the message body.
 * The MediaWiki provided  processor will add   and   to the log event.


 * Handlers
 * Each logger should have one or more handlers attached to it.
 * writes log events to a file or PHP stream.
 * MediaWiki's  can take the same file or UDP endpoint syntax as used by $wgDebugLogGroups.


 * Formatters
 * The formatters normalize and format incoming records for the handlers. If not specified in the config, a default formatter will be selected by the handler.
 * mimics the legacy log message formatting of,  ,   and   global functions by delegating the formatting to.

Minimal example
This configuration logs everything to a single file,. The file should be writable by MediaWiki (e. g. ). Each log entry corresponds to a single line, and the structured data is appended to the message as JSON.

Example from MediaWiki-Vagrant's "elk" role
You can setup logging to an Elasticsearch, Logstash and Kibana (ELK) log aggregation stack in MediaWiki-Vagrant by enabling the  role:

This role configures the wiki to log to local files and also to feed Logstash via an intermediate Redis queue.