Jump to content

Manual:$wgDebugLogGroups: Difference between revisions

From mediawiki.org
Content deleted Content added
Some common debug log groups
mNo edit summary
 
(31 intermediate revisions by 12 users not shown)
Line 1: Line 1:
<languages/>
<languages />
{{TNT|SettingSummary
{{SettingSummary
|name=DebugLogGroups
|name=DebugLogGroups
|version_min=1.5.0
|version_min=1.5.0
|rev_introduced=10598
|rev_introduced=10598
|section=Debug/logging
|section=Debug/logging
|range=<translate><!--T:1--> array of log group keys to filenames</translate>
|range=(<translate><!--T:1--> array of log group keys to filenames</translate>)
|default=array()
|default=<code>[]</code>
|summary=<translate><!--T:2--> Direct <tvar|DebugLog><code>wfDebugLog()</code></> output for certain groups to files other than <tvar|DebugLogFile><code>{{ll|Manual:$wgDebugLogFile|$wgDebugLogFile}}</code></>.</translate>
|summary=<translate><!--T:2--> Direct <tvar name=1><code>wfDebugLog()</code></tvar> output for certain groups to files other than <tvar name=2><code>{{ll|Manual:$wgDebugLogFile|$wgDebugLogFile}}</code></tvar>.</translate>
}}
}}
<translate>
<translate>
== Details == <!--T:3-->
== Details == <!--T:3-->

<!--T:4-->
Set to an array of log group keys to filenames.</translate>
<translate>
<!--T:5-->
If set, <tvar|DebugLog><code>wfDebugLog()</code></> output for that group will go to that file instead of the regular <tvar|DebugLogFile><code>{{ll|Manual:$wgDebugLogFile|$wgDebugLogFile}}</code></>.</translate>
<translate>
<!--T:6-->
Useful for enabling selective logging in production.
</translate>
</translate>
<translate><!--T:4--> Set to an array of log group keys to filenames.</translate>
<translate><!--T:5--> If set, <tvar name=1><code>wfDebugLog()</code></tvar> output for that group will go to that file instead of the regular <tvar name=2><code>{{ll|Manual:$wgDebugLogFile|$wgDebugLogFile}}</code></tvar>.</translate>
<translate><!--T:6--> Useful for enabling selective logging in production.</translate>


{{Note|1=<translate><!--T:9--> If a group is configured in <tvar|DebugLogGroups><code>$wgDebugLogGroups</code></>, then all debug messages with the according group key will be logged to that file, ''also'' if <tvar|DebugLogFile><code>$wgDebugLogFile</code></> is '''not''' set!</translate> <translate><!--T:10--> With other words: If a group key is configured in <tvar|DebugLogGroups><code>$wgDebugLogGroups</code></>, messages will be written, even if an empty value of <tvar|DebugLogFile><code>$wgDebugLogFile</code></> generally disables debugging.</translate>}}
{{Note|1=<translate><!--T:9--> If a group is configured in <tvar name=1><code>$wgDebugLogGroups</code></tvar>, then all debug messages with the according group key will be logged to that file, ''also'' if <tvar name=2><code>$wgDebugLogFile</code></tvar> is '''not''' set!</translate> <translate><!--T:10--> With other words: If a group key is configured in <tvar name=1><code>$wgDebugLogGroups</code></tvar>, messages will be written, even if an empty value of <tvar name=2><code>$wgDebugLogFile</code></tvar> generally disables debugging.</translate>}}


<translate>
<translate>
Line 29: Line 23:


<!--T:12-->
<!--T:12-->
* false to completely remove from the output, including from $wgDebugLogFile.</translate>
* false to completely remove from the output, including from <tvar name=1>$wgDebugLogFile</tvar>.</translate>
<translate>
<translate>
<!--T:13-->
<!--T:13-->
Line 36: Line 30:
<!--T:14-->
<!--T:14-->
* associative array with keys:</translate>
* associative array with keys:</translate>
** <code>destination</code> - <translate><!--T:15--> desired filename or URI.</translate>
<translate>
** <code>sample</code> - <translate><!--T:16--> an integer value, specifying a sampling factor (optional)</translate>
<!--T:15-->
** <code>level</code> - <translate><!--T:17--> A <tvar name=psrloglevel><code>\Psr\Log\LogLevel</code></tvar> constant, indicating the minimum log level (optional, since 1.25)</translate>
** 'destination' desired filename or URI.</translate>
<translate>
<!--T:16-->
** 'sample' an integer value, specifying a sampling factor (optional)</translate>
<translate>
<!--T:17-->
** 'level' A \Psr\Log\LogLevel constant, indicating the minimum level log (optional, since 1.25)


<translate>
<!--T:18-->
<!--T:18-->
When <tvar|MWLoggerDefaultSpi><code>{{ll|Manual:$wgMWLoggerDefaultSpi|$wgMWLoggerDefaultSpi}}</code></> is set to a non-default value, <tvar|DebugLogGroups><code>$wgDebugLogGroups</code></> will probably be ignored, and the method of configuring log files will be determined by whatever logging system is invoked by <tvar|MWLoggerDefaultSpi><code>$wgMWLoggerDefaultSpi</code></>.
When <tvar name=1><code>{{ll|Manual:$wgMWLoggerDefaultSpi|$wgMWLoggerDefaultSpi}}</code></tvar> is set to a non-default value, <tvar name=2><code>$wgDebugLogGroups</code></tvar> will probably be ignored, and the method of configuring log files will be determined by whatever logging system is invoked by <tvar name=3><code>$wgMWLoggerDefaultSpi</code></tvar>.


== Example == <!--T:7-->
== Example == <!--T:7-->
</translate>


<translate>
<!--T:8-->
<!--T:8-->
This example logs debug messages of group "ConfirmEditExtension" to "debug-ext_confirmedit.log" and those of group "SpamRegex" to "debug-spam.log".
This example logs debug messages of group "<tvar name=1>ConfirmEditExtension</tvar>" to "<tvar name=2>debug-ext_confirmedit.log</tvar>" and those of group "<tvar name=3>SpamRegex</tvar>" to "<tvar name=4>debug-spam.log</tvar>".
</translate>
</translate>


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
$wgDebugLogGroups = array(
$wgDebugLogGroups = [
'ConfirmEditExtension' => $IP . '/../../home/debug-ext_confirmedit.log',
'ConfirmEditExtension' => $IP . '/../../home/debug-ext_confirmedit.log',
'SpamRegex' => $IP . '/../../home/debug-spam.log',
'SpamRegex' => $IP . '/../../home/debug-spam.log',
);
];
</syntaxhighlight>
</syntaxhighlight>


Line 79: Line 66:


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
$wgDebugLogGroups['memcached'] = array(
$wgDebugLogGroups['memcached'] = [
'destination' => '/var/log/mediawiki/memcached.log',
'destination' => '/var/log/mediawiki/memcached.log',
'sample' => 1000, // <translate><!--T:21--> log 1 message out of every 1,000.</translate>
'sample' => 1000, // <translate nowrap><!--T:21--> log 1 message out of every 1,000.</translate>
'level' => \Psr\Log\LogLevel::WARNING,
'level' => \Psr\Log\LogLevel::WARNING,
);
];
$wgDebugLogGroups['redis'] = array(
$wgDebugLogGroups['redis'] = [
'destination' => '/var/log/mediawiki/redis.log',
'destination' => '/var/log/mediawiki/redis.log',
// <translate><!--T:22--> Level can also be the literal string value of any Psr\Log\LogLevel constant</translate>
// <translate nowrap><!--T:22--> Level can also be the literal string value of any Psr\Log\LogLevel constant</translate>
'level' => 'info',
'level' => 'info',
);
];
</syntaxhighlight>
</syntaxhighlight>


<translate>
== Some common debug log groups ==
<!--T:37-->
* <code>exception</code>, <code>error</code>, <code>fatal</code> - errors
; Multiple log groups in a single file:
* <code>objectcache</code>, <code>caches</code>, <code>memcached</code>/<code>SQLBagOStuff</code> - [[Manual:$wgObjectCaches|cache]]
: You might want to setup a temporary configuration like the following to see all authentication related logging to trouble-shoot authentication.
* <code>DBPerformance</code>, <code>DBReplication</code>, <code>DBConnection</code> - database
</translate>
* <code>DBQuery</code> - all DB queries
<syntaxhighlight lang="php">
* <code>cookie</code> - response cookies
$wgDebugLogGroups['cookie'] =
* <code>exec</code> - shell commands
$wgDebugLogGroups['session'] =
* <code>session</code> - [[Manual:SessionManager|SessionManager]]
$wgDebugLogGroups['SimpleSAMLphp'] =
* <code>authentication</code>, <code>login</code> - [[Manual:AuthManager|AuthManager]]
$wgDebugLogGroups['PluggableAuth'] = "$IP/cache/PluggableAuth.log";
* <code>ratelimit</code>, <code>throttler</code> - hitting rate limits ([[Manual:$wgRateLimits|$wgRateLimits]] and other)
</syntaxhighlight>

<translate>

== Some common debug log groups == <!--T:26-->
</translate>
* <code>exception</code>, <code>error</code>, <code>fatal</code> - <translate><!--T:27--> errors</translate>
* <code>deprecated</code> - <translate><!--T:28--> deprecation warnings</translate>
* <code>objectcache</code>, <code>caches</code>, <code>memcached</code>/<code>SQLBagOStuff</code> - {{ll|Manual:$wgObjectCaches|2=<translate><!--T:24--> cache</translate>}}
* <code>rdbms</code> - <translate><!--T:29--> database</translate> (including, if {{ll|Manual:$wgDebugDumpSql|$wgDebugDumpSql}} is set, all DB queries)
* <code>cookie</code> - <translate><!--T:31--> response cookies</translate>
* <code>exec</code> - <translate><!--T:32--> shell commands</translate>
* <code>session</code> - {{ll|Manual:SessionManager|SessionManager}}
* <code>authentication</code>, <code>login</code> - {{ll|Manual:AuthManager|AuthManager}}
* <code>ratelimit</code>, <code>throttler</code> - <translate><!--T:33--> hitting rate limits (<tvar name=1>{{ll|Manual:$wgRateLimits|$wgRateLimits}}</tvar> and other)</translate>
* <code>resourceloader</code>, <code>ResourceLoaderImage</code> - [[ResourceLoader]]
* <code>resourceloader</code>, <code>ResourceLoaderImage</code> - [[ResourceLoader]]
* <code>http</code>, <code>HttpError</code> - HTTP requests to external services (via the <code>Http</code>/<code>MwHttpRequest</code> classes)
* <code>http</code>, <code>HttpError</code> - <translate><!--T:34--> HTTP requests to external services (via the <tvar name=1><code>Http</code>/<code>MwHttpRequest</code></tvar> classes)</translate>
* <code>api</code> - [[API:Main Page|API]]
* <code>api</code> - {{ll|API:Main page|2=<translate><!--T:25--> API</translate>}}
* <code>thumbnail</code>, <code>fileupload</code>, <code>fileconcatenate</code> - image-related
* <code>thumbnail</code>, <code>fileupload</code>, <code>fileconcatenate</code> - <translate><!--T:35--> image-related</translate>
* <code>runJobs</code> - [[Manual:Job queue|job queue]]
* <code>runJobs</code> - {{ll|Manual:Job queue|nsp=0}}
* <code>parser</code>, <code>ParserCache</code> - [[Manual:Parser|parser]]
* <code>parser</code>, <code>ParserCache</code> - {{ll|Manual:Parser|nsp=0}}
* <code>slow-parse</code> - warnings about pages that take long to parse
* <code>slow-parse</code> - <translate><!--T:36--> warnings about pages that take long to parse</translate>


[[Category:Log variables{{translation}}|{{PAGENAME}}]]
[[Category:Log variables{{#translation:}}|{{PAGENAME}}]]

Latest revision as of 00:03, 27 December 2023

Debug: $wgDebugLogGroups
Direct wfDebugLog() output for certain groups to files other than $wgDebugLogFile .
Introduced in version:1.5.0 (r10598)
Removed in version:Still in use
Allowed values:(array of log group keys to filenames)
Default value:[]

Details

[edit]

Set to an array of log group keys to filenames. If set, wfDebugLog() output for that group will go to that file instead of the regular $wgDebugLogFile . Useful for enabling selective logging in production.

If a group is configured in $wgDebugLogGroups, then all debug messages with the according group key will be logged to that file, also if $wgDebugLogFile is not set! With other words: If a group key is configured in $wgDebugLogGroups, messages will be written, even if an empty value of $wgDebugLogFile generally disables debugging.

Log destinations may be one of the following:

  • false to completely remove from the output, including from $wgDebugLogFile.
  • string values specifying a filename or URI.
  • associative array with keys:
    • destination - desired filename or URI.
    • sample - an integer value, specifying a sampling factor (optional)
    • level - A \Psr\Log\LogLevel constant, indicating the minimum log level (optional, since 1.25)

When $wgMWLoggerDefaultSpi is set to a non-default value, $wgDebugLogGroups will probably be ignored, and the method of configuring log files will be determined by whatever logging system is invoked by $wgMWLoggerDefaultSpi.

Example

[edit]

This example logs debug messages of group "ConfirmEditExtension" to "debug-ext_confirmedit.log" and those of group "SpamRegex" to "debug-spam.log".

$wgDebugLogGroups = [
	'ConfirmEditExtension'	=> $IP . '/../../home/debug-ext_confirmedit.log',
	'SpamRegex'		=> $IP . '/../../home/debug-spam.log',
];

Example:

$wgDebugLogGroups['redis'] = '/var/log/mediawiki/redis.log';

Advanced example:

 $wgDebugLogGroups['memcached'] = [
     'destination' => '/var/log/mediawiki/memcached.log',
     'sample' => 1000,  // log 1 message out of every 1,000.
     'level' => \Psr\Log\LogLevel::WARNING,
 ];
 $wgDebugLogGroups['redis'] = [
     'destination' => '/var/log/mediawiki/redis.log',
     // Level can also be the literal string value of any Psr\Log\LogLevel constant
     'level' => 'info',
 ];
Multiple log groups in a single file
You might want to setup a temporary configuration like the following to see all authentication related logging to trouble-shoot authentication.
$wgDebugLogGroups['cookie'] =
	$wgDebugLogGroups['session'] =
	$wgDebugLogGroups['SimpleSAMLphp'] =
	$wgDebugLogGroups['PluggableAuth'] = "$IP/cache/PluggableAuth.log";


Some common debug log groups

[edit]
  • exception, error, fatal - errors
  • deprecated - deprecation warnings
  • objectcache, caches, memcached/SQLBagOStuff - cache
  • rdbms - database (including, if $wgDebugDumpSql is set, all DB queries)
  • cookie - response cookies
  • exec - shell commands
  • session - SessionManager
  • authentication, login - AuthManager
  • ratelimit, throttler - hitting rate limits ($wgRateLimits and other)
  • resourceloader, ResourceLoaderImage - ResourceLoader
  • http, HttpError - HTTP requests to external services (via the Http/MwHttpRequest classes)
  • api - API
  • thumbnail, fileupload, fileconcatenate - image-related
  • runJobs - Job queue
  • parser, ParserCache - Parser
  • slow-parse - warnings about pages that take long to parse