Manual talk:Structured logging

About this board

Use one of the core logging channels?

2
Summary by GregRundlett

Brian's comments helped me understand the different logging mechanisms, and the usage of each.

GregRundlett (talkcontribs)

In order to instantiate a LoggerFactory instance (when NOT coding for an extension), the manual says to "use one of the core logging channels". Is this supposed to be defined or standardized somewhere like Manual:$wgLogTypes is? Because when I search core, there are dozens of different "channels" and there doesn't seem to be any rhyme or reason to them. The manual might as well say "use any string".

BDavis (WMF) (talkcontribs)

Yes, it really is basically "use any string that is configured to record debug log events to a file in your local MediaWiki deployment". There is no central codified list of widely used log channels.

For a deployment where $wgDebugLogFile logging is being used it really does not matter. For a deployment like the Wikimedia production cluster where individual log channels are selectively enabled then the choice does make a difference. When converting a wfDebugLog() call, use the same channel name. When converting a wfDebug() call, use your best judgement for selecting an existing channel or creating a new channel using an arbitrary string.

Doesn't work in extensions??

3
Summary by Legoktm

Missing use statement

Subfader (talkcontribs)
$mylog = LoggerFactory::getInstance( "mylog" );
$mylog->debug( "Foo bar" );

>>

Fatal error: Class 'LoggerFactory' not found in .../extensions/CharInsert/CharInsert.body.php on line 15
Legoktm (talkcontribs)

Do you have a use MediaWiki\Logger\LoggerFactory; at the top of the file?

Subfader (talkcontribs)

Thanks, that fixed it.

There are no older topics