<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.mediawiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=98.222.146.27</id>
	<title>MediaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.mediawiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=98.222.146.27"/>
	<link rel="alternate" type="text/html" href="https://www.mediawiki.org/wiki/Special:Contributions/98.222.146.27"/>
	<updated>2026-08-23T02:12:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.47.0-wmf.16</generator>
	<entry>
		<id>https://www.mediawiki.org/w/index.php?title=Requests_for_comment/Structured_logging&amp;diff=3023525</id>
		<title>Requests for comment/Structured logging</title>
		<link rel="alternate" type="text/html" href="https://www.mediawiki.org/w/index.php?title=Requests_for_comment/Structured_logging&amp;diff=3023525"/>
		<updated>2018-12-24T17:05:13Z</updated>

		<summary type="html">&lt;p&gt;98.222.146.27: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RFC&lt;br /&gt;
| created = 2013-12-03&lt;br /&gt;
| authors = [[User:BDavis (WMF)|Bryan Davis]], [[User:Ori.livneh|Ori Livneh]], [[User:Aaron Schulz|Aaron Schulz]]&lt;br /&gt;
| status = implemented&lt;br /&gt;
| extrastatus = This RfC was never formally approved, but the [[#Implementation|gerrit changes to implement PSR-3 support]] have been merged --[[User:BDavis (WMF)|BDavis (WMF)]] ([[User talk:BDavis (WMF)|talk]]) 15:44, 10 April 2015 (UTC)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This is a &#039;&#039;&#039;request for comment&#039;&#039;&#039; about adding &#039;&#039;&#039;Structured logging&#039;&#039;&#039; to MediaWiki. It specifies a data model for MediaWiki log messages and an interface for generating log messages that conform to the model.&lt;br /&gt;
&lt;br /&gt;
By &amp;quot;data model&amp;quot; we simply mean an agreed-upon set of fields containing metadata that describes the context in which the log message was generated. The model specifies the name of each field and the value it can hold. Log messages generated via the interface that we propose below would conform to this model, allowing them to be serialized to a machine-readable format.A standard for machine-readable metadata common to all log messages would make it possible to query, collate, and summarize operational data in ways that are currently very difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
We think that the ability to cross-reference logs and query by context will make troubleshooting bugs easier. We also think that ongoing analysis of aggregated log data would reveal which files, interfaces, and code paths are especially prone to bugs or poor performance, and that this information would help us make MediaWiki more reliable and performant.&lt;br /&gt;
&lt;br /&gt;
=== Problems with the current interface ===&lt;br /&gt;
Most operational logging in MediaWiki is done via &amp;lt;code&amp;gt;wfDebugLog&amp;lt;/code&amp;gt; calls. Messages logged via &amp;lt;code&amp;gt;wfDebugLog&amp;lt;/code&amp;gt; specify a topic name (or a log bucket). This name usually identifies the name of the component that is emitting the log message. Some parts of the code which generate different kinds of log messages have compound topic names that describe the type of log message being logged, usually in terms of severity (&amp;quot;memcached-serious&amp;quot;, for example). The ad hoc overloading of the log group property to encode severity is a good example of existing usage that is twisting the interface to overcome its limitations. This is a good indication that the current interface is inadequate.&lt;br /&gt;
&lt;br /&gt;
Because there is no established standard for encoding severity, the density of logging calls in MediaWiki code varies greatly. Access to the production logs is limited, and many developers will only ever review logs generated on their development instance and consequently fail to appreciate the cost of excessively verbose logging at scale. The instrumentation of code is often pitched to its initial development rather than its ongoing maintenance.&lt;br /&gt;
&lt;br /&gt;
To keep chatty code from drowning out important log data, the logging setup on the Wikimedia production cluster does not automatically transmit all logging topics to the log processor. A developer must first manually enroll the log bucket by adding it to the &amp;lt;code&amp;gt;$wgDebugLogGroups&amp;lt;/code&amp;gt; configuration var. The problem with this approach is that the absence of log data from a particular component is typically noticed when it is needed the most: that is, when the component is suspected of misbehaving in ways that are difficult to reproduce or reason about. Thus log buckets are usually enabled to help solve a particular bug, and they are commonly left enabled long after the motivation for enabling them has ceased to be relevant. The overall effect is that Wikimedia&#039;s logs are curated on the basis of historic interest rather than abiding relevance.&lt;br /&gt;
&lt;br /&gt;
== Current logging ==&lt;br /&gt;
; wfDebug( $text, $logonly = false )&lt;br /&gt;
: Logs developer provided free-form text + optional global prefix string&lt;br /&gt;
: Possibly has time-elapsed since start of request and real memory usage inserted between prefix and message&lt;br /&gt;
: Delegates to &amp;lt;code&amp;gt;wfErrorLog()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; wfDebugMem( $exact = false )&lt;br /&gt;
: Uses &amp;lt;code&amp;gt;wfDebug()&amp;lt;/code&amp;gt; to log &amp;quot;Memory usage: N (kilo)?bytes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
; wfDebugLog( $logGroup, $text, $public = true)&lt;br /&gt;
: Logs either to a custom log sink defined in &amp;lt;code&amp;gt;$wgDebugLogGroups&amp;lt;/code&amp;gt; or via &amp;lt;code&amp;gt;wfDebug()&amp;lt;/code&amp;gt;&lt;br /&gt;
: &#039;&#039;&#039;Default&#039;&#039;&#039;&lt;br /&gt;
:: Prepends &amp;quot;[$logGroup] &amp;quot; to message&lt;br /&gt;
: &#039;&#039;&#039;Custom sink&#039;&#039;&#039;&lt;br /&gt;
:: May log only a fraction of occurrences via &amp;lt;code&amp;gt;mt_rand()&amp;lt;/code&amp;gt; sampling&lt;br /&gt;
:: Prepends &amp;lt;code&amp;gt;wfTimestamp( TS_DB ) wfWikiID() wfHostname(): &amp;lt;/code&amp;gt; to message&lt;br /&gt;
:: Delegates to &amp;lt;code&amp;gt;wfErrorLog()&amp;lt;/code&amp;gt; to actually write to sink&lt;br /&gt;
&lt;br /&gt;
; wfLogDBError( $text )&lt;br /&gt;
: Enabled/disabled with &amp;lt;code&amp;gt;$wgDBerrorLog&amp;lt;/code&amp;gt; sink location&lt;br /&gt;
: Logs &amp;quot;$date\t$host\t$wiki\$text&amp;quot; via &amp;lt;code&amp;gt;wfErrorLog()&amp;lt;/code&amp;gt; to  &amp;lt;code&amp;gt;$wgDBerrorLog&amp;lt;/code&amp;gt; sink&lt;br /&gt;
: Date format is &amp;lt;code&amp;gt;&#039;D M j G:i:s T Y&#039;&amp;lt;/code&amp;gt; with possible custom timezone specified by &amp;lt;code&amp;gt;$wgDBerrorLogTZ&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; wfErrorLog( $text, $file )&lt;br /&gt;
: Writes &amp;lt;code&amp;gt;$text&amp;lt;/code&amp;gt; to either a local file or a UDP packet depending on the value of &amp;lt;code&amp;gt;$file&amp;lt;/code&amp;gt;&lt;br /&gt;
: &#039;&#039;&#039;UDP&#039;&#039;&#039;&lt;br /&gt;
:: If &amp;lt;code&amp;gt;$file&amp;lt;/code&amp;gt; ends with a string following the host name/IP it will be used as a prefix to &amp;lt;code&amp;gt;$text&amp;lt;/code&amp;gt;&lt;br /&gt;
:: The final message with optional prefix added will be trimmed to 65507 bytes and a trailing newline may be added&lt;br /&gt;
: &#039;&#039;&#039;FILE&#039;&#039;&#039;&lt;br /&gt;
:: &amp;lt;code&amp;gt;$text&amp;lt;/code&amp;gt; will be appended to file unless the resulting file size would be &amp;gt;= 0x7fffffff bytes (~2G)&lt;br /&gt;
&lt;br /&gt;
; wfLogProfilingData()&lt;br /&gt;
: Delegates to &amp;lt;code&amp;gt;wfErrorLog()&amp;lt;/code&amp;gt; using &amp;lt;code&amp;gt;$wgDebugLogFile&amp;lt;/code&amp;gt; sink&lt;br /&gt;
: Creates a tab delimited log message including timestamp, elapsed request time, requesting IPs, and request URL followed by a newline and the profiler output.&lt;br /&gt;
: Date is from &amp;lt;code&amp;gt;gmdate( &#039;YmdHis&#039; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Recent changes logging&lt;br /&gt;
; Transport and serialization format may be specified via &amp;lt;code&amp;gt;$wgRCFeeds&amp;lt;/code&amp;gt;&lt;br /&gt;
; Various implementations in &amp;lt;code&amp;gt;includes/rcfeeds/&amp;lt;/code&amp;gt;, including IRC, UDP &amp;amp; Redis.&lt;br /&gt;
&lt;br /&gt;
== Proposal ==&lt;br /&gt;
&lt;br /&gt;
=== Serialization Format ===&lt;br /&gt;
Rather than dive down a rabbit hole of trying to find a universal spec for log file formats let&#039;s just keep things simple. PHP loves dictionaries (well they call them arrays but whatever; key=value collections) and has a pretty fast json formatter. So the simplest thing that will work reasonably well would be to keep log events internally as PHP arrays and serialize them as json objects. This will be relatively easy to recreate on other internally developed applications as well with the possible exception of apps written in low level languages such as C that don&#039;t have ready made key=value data structures.&lt;br /&gt;
&lt;br /&gt;
=== Data collected ===&lt;br /&gt;
Here&#039;s a list of the data points that we should definitely have:&lt;br /&gt;
; timestamp&lt;br /&gt;
: Local system time that event occurred either as UNIX epoch timestamp or [[:en:ISO_8601|ISO 8601]] formatted string&lt;br /&gt;
: &amp;lt;code&amp;gt;date( &#039;c&#039; )&amp;lt;/code&amp;gt;&lt;br /&gt;
; host&lt;br /&gt;
: FQDN of system where event occurred&lt;br /&gt;
: &amp;lt;code&amp;gt;php_uname( &#039;n&#039; )&amp;lt;/code&amp;gt;&lt;br /&gt;
; source&lt;br /&gt;
: Name of application generating events; correlates to &#039;&#039;&#039;APP-NAME&#039;&#039;&#039; of [https://tools.ietf.org/html/rfc5424#section-6.2.5 RFC 5424]&lt;br /&gt;
: &amp;lt;code&amp;gt;&#039;Mediawiki&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
; pid&lt;br /&gt;
: Unix process id, thread id, thread name or other process identifier&lt;br /&gt;
: &amp;lt;code&amp;gt;getmypid()&amp;lt;/code&amp;gt;&lt;br /&gt;
; severity&lt;br /&gt;
: Message severity ([[:en:Syslog#Severity_levels|RFC 5424 levels]])&lt;br /&gt;
: &amp;lt;code&amp;gt;&#039;WARN&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
; channel&lt;br /&gt;
: Log channel. Often the function/module/class creating message (similar to &amp;lt;code&amp;gt;wgDebugLogGroups&amp;lt;/code&amp;gt; groups)&lt;br /&gt;
: &amp;lt;code&amp;gt;get_class( $this )&amp;lt;/code&amp;gt;&lt;br /&gt;
; message&lt;br /&gt;
: Message body&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;quot;Help! I&#039;m trapped in a logger factory!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally we suggest adding a semi-structured &amp;quot;context&amp;quot; component to logs. This would be a collection of key=value pairs that the developers determine to be useful for debugging. There should be two different methods available to add such data. The first is as an optional argument to the logging method itself and the second is a global collection patterned after the Log4J Mapped Diagnostic Context (MDC).&lt;br /&gt;
&lt;br /&gt;
The local collection is useful for obvious reasons such as attaching class/method state data to the log output and deferring stringification of resources in the event that runtime configuration is ignoring messages of the provided level.&lt;br /&gt;
&lt;br /&gt;
; file&lt;br /&gt;
: Source file triggering message&lt;br /&gt;
; line&lt;br /&gt;
: Source line triggering message&lt;br /&gt;
; errcode&lt;br /&gt;
: Numeric or string identifier for the error&lt;br /&gt;
; exception&lt;br /&gt;
: Live exception object to be stringified by the log event emitter&lt;br /&gt;
; args&lt;br /&gt;
: key=value map of method arguments&lt;br /&gt;
&lt;br /&gt;
The global collection is very useful for attaching global application state data to all log messages that may be emitted. Examples of data that could be included:&lt;br /&gt;
; vhost&lt;br /&gt;
: Apache vhost processing request&lt;br /&gt;
: &amp;lt;code&amp;gt;$_SERVER[&#039;HTTP_HOST&#039;]&amp;lt;/code&amp;gt;&lt;br /&gt;
; ip&lt;br /&gt;
: Requesting ip address&lt;br /&gt;
: &amp;lt;code&amp;gt;$_SERVER[&#039;REMOTE_ADDR&#039;]&amp;lt;/code&amp;gt;&lt;br /&gt;
; user&lt;br /&gt;
: Authenticated user identity&lt;br /&gt;
; req&lt;br /&gt;
: Request ID; UUID or similar token that can be used to correlate all log messages connected to a given request&lt;br /&gt;
&lt;br /&gt;
=== API ===&lt;br /&gt;
The developer facing API is the [https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md PSR-3 logging interface standard].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
namespace Psr\Log;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Describes a logger instance&lt;br /&gt;
 *&lt;br /&gt;
 * The message MUST be a string or object implementing __toString().&lt;br /&gt;
 *&lt;br /&gt;
 * The message MAY contain placeholders in the form: {foo} where foo&lt;br /&gt;
 * will be replaced by the context data in key &amp;quot;foo&amp;quot;.&lt;br /&gt;
 *&lt;br /&gt;
 * The context array can contain arbitrary data, the only assumption that&lt;br /&gt;
 * can be made by implementors is that if an Exception instance is given&lt;br /&gt;
 * to produce a stack trace, it MUST be in a key named &amp;quot;exception&amp;quot;.&lt;br /&gt;
 *&lt;br /&gt;
 * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md&lt;br /&gt;
 * for the full interface specification.&lt;br /&gt;
 */&lt;br /&gt;
interface LoggerInterface&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * System is unusable.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function emergency($message, array $context = array());&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Action must be taken immediately.&lt;br /&gt;
     *&lt;br /&gt;
     * Example: Entire website down, database unavailable, etc. This should&lt;br /&gt;
     * trigger the SMS alerts and wake you up.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function alert($message, array $context = array());&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Critical conditions.&lt;br /&gt;
     *&lt;br /&gt;
     * Example: Application component unavailable, unexpected exception.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function critical($message, array $context = array());&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Runtime errors that do not require immediate action but should typically&lt;br /&gt;
     * be logged and monitored.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function error($message, array $context = array());&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Exceptional occurrences that are not errors.&lt;br /&gt;
     *&lt;br /&gt;
     * Example: Use of deprecated APIs, poor use of an API, undesirable things&lt;br /&gt;
     * that are not necessarily wrong.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function warning($message, array $context = array());&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Normal but significant events.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function notice($message, array $context = array());&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Interesting events.&lt;br /&gt;
     *&lt;br /&gt;
     * Example: User logs in, SQL logs.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function info($message, array $context = array());&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Detailed debug information.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function debug($message, array $context = array());&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Logs with an arbitrary level.&lt;br /&gt;
     *&lt;br /&gt;
     * @param mixed $level&lt;br /&gt;
     * @param string $message&lt;br /&gt;
     * @param array $context&lt;br /&gt;
     * @return null&lt;br /&gt;
     */&lt;br /&gt;
    public function log($level, $message, array $context = array());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;MediaWiki\Logger\LoggerFactory&#039;&#039;&#039; provides static methods for registering PSR-3 providers and getting PSR-3 Logger instances from the current provider:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    /**&lt;br /&gt;
     * Get a named logger instance from the currently configured logger factory.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $channel Logger channel (name)&lt;br /&gt;
     * @return Psr\Log\LoggerInterface&lt;br /&gt;
     */&lt;br /&gt;
    public static function getInstance( $channel );&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Register a service provider to create new \Psr\Log\LoggerInterface&lt;br /&gt;
     * instances.&lt;br /&gt;
     *&lt;br /&gt;
     * @param \MediaWiki\Logger\Spi $provider Provider to register&lt;br /&gt;
     */&lt;br /&gt;
    public static function registerProvider( Spi $provider );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;MediaWiki\Logger\LoggerFactory::getInstance()&amp;lt;/code&amp;gt; method is the means by which most code would acquire an Psr\Log\LoggerInterface instance. It will in turn delegate the creation of Psr\Log\LoggerInterface to a class implementing the &amp;lt;code&amp;gt;MediaWiki\Logger\Spi&amp;lt;/code&amp;gt; interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
namespace MediaWiki\Logger;&lt;br /&gt;
interface Spi {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Get a logger instance.&lt;br /&gt;
     *&lt;br /&gt;
     * @param string $channel Logging channel&lt;br /&gt;
     * @return Psr\Log\LoggerInterface Logger instance&lt;br /&gt;
     */&lt;br /&gt;
    public function getLogger( $channel );&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This service provider interface will allow the backend logging library to implemented in multiple ways.  The &amp;lt;code&amp;gt;$wgMWLoggerDefaultSpi&amp;lt;/code&amp;gt; global provides the class name of the default &amp;lt;code&amp;gt;MediaWiki\Logger\Spi&amp;lt;/code&amp;gt; implementation. This can be altered via the normal means. Alternately &amp;lt;code&amp;gt;MediaWiki\Logger\LoggerFactory::registerProvider()&amp;lt;/code&amp;gt; can be invoked early in the application setup to inject an alternate SPI implementation.&lt;br /&gt;
&lt;br /&gt;
=== Managing third-party libraries ===&lt;br /&gt;
The use of [http://www.php-fig.org/psr/psr-3 PSR-3] and [https://github.com/Seldaek/monolog monolog] introduces the need to manage third-party code dependencies for MediaWiki core. Although there are some third-party components in includes/libs, to my knowledge this is the first large scale use of external PHP code by MediaWiki core.&lt;br /&gt;
&lt;br /&gt;
In a more perfect world, MediaWiki would already be a system that assembled a collection of libraries using a well defined dependency management system. This has actually been envisioned in at least two RFCs ([[../MediaWiki libraries/]] and [[../Third-party components/]]).&lt;br /&gt;
&lt;br /&gt;
Several possible solutions were examined and ultimately the use of [https://getcomposer.org/ Composer] as a dependency management system was chosen. The use of [http://www.php-fig.org/psr/psr-3 PSR-3] is mandatory so this library was added to the &amp;quot;require&amp;quot; section of &amp;lt;code&amp;gt;composer.json&amp;lt;/code&amp;gt; in the mediawiki/core.git repository. The use of [https://github.com/Seldaek/monolog monolog] is optional, so it was added to the &amp;quot;suggest&amp;quot; section. Since this &amp;lt;code&amp;gt;composer.json&amp;lt;/code&amp;gt; file is in the root of the MediaWiki core project, it does to some extent conflict with the [[../Extension management with Composer/]] RFC. Additional work is being done to mitigate this problem for users who were already making use of &amp;lt;code&amp;gt;composer.json&amp;lt;/code&amp;gt; ([[phab:T67188]]).&lt;br /&gt;
&lt;br /&gt;
The [[../Composer managed libraries for use on WMF cluster/]] RFC was written and subsequently approved to deal with the process of staging and deploying Composer managed content in the WMF production environment. Installations of MediaWiki via git clones are expected to manage libraries themselves by using the &amp;lt;code&amp;gt;mediawiki/vendor.git&amp;lt;/code&amp;gt; repo, using Composer directly, or creating a &amp;lt;code&amp;gt;mediawiki/vendor.git&amp;lt;/code&amp;gt; work-alike for their particular deployment. Releases will be expected to include the required libraries in the official tarball.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
An original proof of concept implementation was submitted as {{gerrit|112699}}. The approach of using Composer to manage external dependencies was given a &#039;&#039;&#039;+1&#039;&#039;&#039; by Tim. The monolithic patch was then split into four smaller patches for closer review and approval:&lt;br /&gt;
&lt;br /&gt;
; {{gerrit|119939}} Add Composer managed libraries {{done}}&lt;br /&gt;
: Require Psr\Log and suggest Monolog libraries to MW-Core via &amp;lt;code&amp;gt;composer.json&amp;lt;/code&amp;gt;.&lt;br /&gt;
; {{gerrit|119940}} Add a PSR-3 based logging interface {{done}}&lt;br /&gt;
: The MWLogger class is actually a thin wrapper around any PSR-3 LoggerInterface implementation. Named MWLogger instances can be obtained from the MWLogger::getInstance() static method. MWLogger expects a class implementing the MWLoggerSpi interface to act as a factory for new MWLogger instances. A concrete MWLoggerSpi implementation using the Monolog library is also provided.&lt;br /&gt;
; {{gerrit|119941}} Enable MWLogger logging for legacy logging methods {{done}}&lt;br /&gt;
: Introduces the &amp;lt;code&amp;gt;MWLoggerLegacyLogger&amp;lt;/code&amp;gt; logger to mimic legacy logging behavior as a PSR-3 compliant logger component and sets it as the default &amp;lt;code&amp;gt;$wgMWLoggerDefaultSpi&amp;lt;/code&amp;gt; implementation. wfDebug, wfDebugLog and wfLogDBError are changed to use &amp;lt;code&amp;gt;MWLogger&amp;lt;/code&amp;gt;.&lt;br /&gt;
; {{gerrit|119942}} Enable MWLogger logging for wfLogProfilingData {{done}}&lt;br /&gt;
: Output structured profiling report data from wfLogProfilingData.&lt;br /&gt;
; {{gerrit|184830}} Replace MWLogger with MWLoggerFactory&lt;br /&gt;
: Design change to replace MWLogger with direct use of PSR-3 interfaces in MediaWiki. {{done}}&lt;br /&gt;
; {{gerrit|198674}} Move MWLogger classes to MediaWiki\Logger namespace&lt;br /&gt;
: Move the MWLogger PSR-3 logging related classes into the MediaWiki\Logger namespace. Create shim classes to ease migration of existing MWLoggerFactory usage to the namespaced classes. {{done}}&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
; Relevant bugs&lt;br /&gt;
:* {{bug|14601|Use wfDebugLog instead of wfDebug by default}}&lt;br /&gt;
:* {{bug|49757|Better monitoring and error reporting of Errors and Exceptions}}&lt;br /&gt;
&lt;br /&gt;
; Related RFCs&lt;br /&gt;
:* [[../Third-party components/]]&lt;br /&gt;
:*[[../MediaWiki libraries/]]&lt;br /&gt;
:*[[../Composer managed libraries for use on WMF cluster/]]&lt;br /&gt;
&lt;br /&gt;
; RFC Review&lt;br /&gt;
:* [[Architecture_meetings/RFC_review_2013-12-04|2013-12-04]]&lt;br /&gt;
:* [[Architecture_meetings/RFC_review_2014-03-19|2013-03-19]]&lt;br /&gt;
&lt;br /&gt;
; Logging standards&lt;br /&gt;
:* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md&lt;br /&gt;
:* http://www.graylog2.org/about/gelf&lt;br /&gt;
:* https://wiki.mozilla.org/Services/Sagrada/Metlog&lt;br /&gt;
:* http://cee.mitre.org/&lt;br /&gt;
&lt;br /&gt;
; Additional commentary on logging&lt;br /&gt;
:* [[User:BDavis_(WMF)/Projects/Structured_logging]]&lt;br /&gt;
:* http://gregoryszorc.com/blog/2012/12/06/thoughts-on-logging---part-1---structured-logging/&lt;br /&gt;
:*  https://journal.paul.querna.org/articles/2011/12/26/log-for-machines-in-json/&lt;br /&gt;
:*  http://carolina.mff.cuni.cz/~trmac/blog/2011/structured-logging/&lt;br /&gt;
:*  http://dev.splunk.com/view/logging-best-practices/SP-CAAADP6&lt;br /&gt;
:*  https://delicious.com/bd808/logging&lt;/div&gt;</summary>
		<author><name>98.222.146.27</name></author>
	</entry>
</feed>