Manual:Logging to Special:Log

Pre 1.19
There are ways to use this system but make it forward compatible with the new system by using the message name format described above. Extra parameters are what are causing most of the issues. You can make the messages like above: And pass empty value for param $1, because the old system will prepend the username automatically; # for $2 to avoid automatic gender feature using the gender of the reader. Custom parameters should start at $4.

An example of adding a new log type called "foo" for your extension, using the LogPage class. In the MyExtension.php file, add:

// Internal name of the log, Special:Log/foo $wgLogTypes[] = 'foo'; // System message containing the friendly name of the log. Shows up // in the page title and the Special:Log dropdown // Use $wgLogNames['foo'] = 'foo-name'; // System message containing the introductory text on Special:Log when this page is shown $wgLogHeaders['foo'] = 'foo-header';

Create system messages for your extension in MyExtension.i18n.php:

$messages['en'] = array( ...                                                       'foo' => 'Foo',  'foo-name' => 'Foo log',  'foo-header' => 'These events track when Foo events happen in the system.',  'foo-message' => 'A Foo event happened to article $1',  ... );

In the body file MyExtension_body.php, add this code, which adds entries in both Special:Log/foo and Special:RecentChanges:

global $wgTitle, $wgUser; $log = new LogPage('foo');   // See alternative below $log->addEntry('foo',              $wgTitle,               wfMsg('foo-message', $wgTitle->getFullText),              array,               $wgUser);

If you don't want your events to show up in Special:RecentChanges, which might cause watchlist notifications, change the constructor to:

$log = new LogPage('foo', false); // Second arg = false