Jump to content

Manual:$wgDebugLogGroups: Difference between revisions

From mediawiki.org
Content deleted Content added
Tag: 2017 source edit
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 7: Line 7:
|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=<code>[]</code>
|default=<code>[]</code>
|summary=<translate><!--T:2--> Direct <tvar|1><code>wfDebugLog()</code></> output for certain groups to files other than <tvar|2><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>
Line 13: Line 13:
</translate>
</translate>
<translate><!--T:4--> Set to an array of log group keys to filenames.</translate>
<translate><!--T:4--> Set to an array of log group keys to filenames.</translate>
<translate><!--T:5--> If set, <tvar|1><code>wfDebugLog()</code></> output for that group will go to that file instead of the regular <tvar|2><code>{{ll|Manual:$wgDebugLogFile|$wgDebugLogFile}}</code></>.</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>
<translate><!--T:6--> Useful for enabling selective logging in production.</translate>


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


<!--T:12-->
<!--T:12-->
* false to completely remove from the output, including from <tvar|1>$wgDebugLogFile</>.</translate>
* false to completely remove from the output, including from <tvar name=1>$wgDebugLogFile</tvar>.</translate>
<translate>
<translate>
<!--T:13-->
<!--T:13-->
Line 30: 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>
** <code>sample</code> - <translate><!--T:16--> an integer value, specifying a sampling factor (optional)</translate>
** <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>

<translate>
<translate>
<!--T:15-->
** '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)

<!--T:18-->
<!--T:18-->
When <tvar|1><code>{{ll|Manual:$wgMWLoggerDefaultSpi|$wgMWLoggerDefaultSpi}}</code></> is set to a non-default value, <tvar|2><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|3><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-->


<!--T:8-->
<!--T:8-->
This example logs debug messages of group "<tvar|1>ConfirmEditExtension</>" to "<tvar|2>debug-ext_confirmedit.log</>" and those of group "<tvar|3>SpamRegex</>" to "<tvar|4>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>


Line 90: Line 85:
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
$wgDebugLogGroups['cookie'] =
$wgDebugLogGroups['cookie'] =
$wgDebugLogGroups['session'] =
$wgDebugLogGroups['session'] =
$wgDebugLogGroups['SimpleSAMLphp'] =
$wgDebugLogGroups['SimpleSAMLphp'] =
$wgDebugLogGroups['PluggableAuth'] = "$IP/cache/PluggableAuth.log";
$wgDebugLogGroups['PluggableAuth'] = "$IP/cache/PluggableAuth.log";
</syntaxhighlight>
</syntaxhighlight>


<translate>
<translate>

== Some common debug log groups == <!--T:26-->
== Some common debug log groups == <!--T:26-->
</translate>
</translate>
Line 101: Line 97:
* <code>deprecated</code> - <translate><!--T:28--> deprecation warnings</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>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 (including, if {{ll|Manual:$wgDebugDumpSql|$wgDebugDumpSql}} is set, all DB queries)</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>cookie</code> - <translate><!--T:31--> response cookies</translate>
* <code>exec</code> - <translate><!--T:32--> shell commands</translate>
* <code>exec</code> - <translate><!--T:32--> shell commands</translate>
* <code>session</code> - {{ll|Manual:SessionManager|SessionManager}}
* <code>session</code> - {{ll|Manual:SessionManager|SessionManager}}
* <code>authentication</code>, <code>login</code> - {{ll|Manual:AuthManager|AuthManager}}
* <code>authentication</code>, <code>login</code> - {{ll|Manual:AuthManager|AuthManager}}
* <code>ratelimit</code>, <code>throttler</code> - <translate><!--T:33--> hitting rate limits (<tvar|1>{{ll|Manual:$wgRateLimits|$wgRateLimits}}</> and other)</translate>
* <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> - <translate><!--T:34--> HTTP requests to external services (via the <tvar|1><code>Http</code>/<code>MwHttpRequest</code></> classes)</translate>
* <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> - {{ll|API:Main page|2=<translate><!--T:25--> API</translate>}}
* <code>api</code> - {{ll|API:Main page|2=<translate><!--T:25--> API</translate>}}
* <code>thumbnail</code>, <code>fileupload</code>, <code>fileconcatenate</code> - <translate><!--T:35--> image-related</translate>
* <code>thumbnail</code>, <code>fileupload</code>, <code>fileconcatenate</code> - <translate><!--T:35--> image-related</translate>

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