Manual:Logging to Special:Log

This page describes how to log actions to Special:Log.

1.19 and later
This is example code for extensions. The same applies for core, but the configuration is in DefaultSettings.php and messages in different places.

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:

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

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

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