Manual:How to debug

,?

To log to one of these groups, call  like this:

Structured logging
Structured logging allows you to include fields in your log records. See  for more information.

Statistics
Advanced client-side logging can be performed with , which requires a complex setup and careful inspection of privacy issues.

Simple counting of certain kind of events is possible (since MediaWiki 1.25) using StatsD. StatsD offers meters, gauges, counters, and timing metrics.

Usage example:

The metrics can be sent to a StatsD server, which may be specified via the  configuration variable. (If not set, the metrics are discarded.) You can work with StatsD locally (without needing a Graphite server) by starting a StatsD server and configuring it with the "backends/console" backend, which will output metrics to the console.

As of MediaWiki 1.25,   is a shortcut for the   method on the main  instance.

Send debug data to an HTML comment in the output
This may occasionally be useful when supporting a non-technical end-user. It's more secure than exposing the debug log file to the web, since the output only contains private data for the current user. But it's not ideal for development use since data is lost on fatal errors and redirects. Use on production sites is not recommended. Debug comments reveal information in page views which could potentially expose security risks.



Working live with MediaWiki objects
 is an interactive script to evaluate and interact with MediaWiki objects and functions in a fully initialized environment.

$ php maintenance/eval.php > print wfMessage("Recentchanges")->plain; Recent changes

The  portable virtual machine integrates the interactive PHP shell   (when using Zend).

Callable updates
Code embedded in the  function, such as   in , is not executed during the web request, so no error message will be displayed if it fails. For debugging, it may be helpful to temporarily remove the code from within the function so that it is executed live.

Client side debugging (JavaScript)
Wikipedia offers a rich set of tools for debugging client side JavaScript. In addition to the MediaWiki tools, other techniques are available to assist with diagnosing client interactions.

Tools:


 * ResourceLoader offers 1>Special:MyLanguage/ResourceLoader/Developing with ResourceLoader#Debugging</>|a means to ensure JavaScript is easily viewable by client-side tools.


 * Open your browser's console. Many client side mediawiki scripts log error messages to the console using ResourceLoader, which provides 1>Special:MyLanguage/ResourceLoader/Modules#mediaWiki.log</>|a safety oriented way to log to the client console. Beyond the native JavaScript logging function, it provides a check to ensure that a console is available and that logging does not produce its own error.  1>Special:MyLanguage/ResourceLoader/Architecture#Debug_mode</>|ResourceLoader/Architecture#Debug_mode also describes this feature.


 * Browser tools may provide native functionality to debug client side script.


 * Network tracers, like [<tvar|url>https://www.wireshark.org/</> Wireshark] can provide insight into the script that is being provided by a page.


 * You can add <tvar|1> </> to your URL as in <tvar|url>https://www.mediawiki.org/wiki/MediaWiki?debug=true</> to get more detailed information for debugging via your browser's console