Manual:Logging to Special:Log

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

Example
This is example illustrates how you would code Special:Log entries for extensions. The log messages appear on the Special:Log page and can be filtered by, for example, the log name, user, title or date range.

In your extension setup file
For core logs, the configuration is in DefaultSettings.php.

In i18n/en.json file
Message documentation (qqq.json):

Adding links
To add a link to log entries, you should pass the page name etc. in the log parameters, and format that in your LogFormatter using. With other methods, non-html output (like UDP feed to IRC) will be broken.

See for an example LogFormatter with links.

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: