Extension:Access Log

The Access Log extension adds a special page to MediaWiki. This special page, which is only accessible by certain privileged users, shows who read or edited a page, and when. It provides options to filter the list by user, action, and/or namespace, and limit the number of days to show. It also provides an option to purge old log entries.

Usage
The AccessLog extension is a MediaWiki Special Page. Only members of the 'sysop' group, and if set, members of the group defined in the  variable, can access this special page. There are two ways to invoke this special page and view the access log:


 * 1) Directly navigate to the page 'Special:AccessLog'.
 * 2) Enter the 'Special Pages' page and click on the AccessLog special page.

The following shows the access log page, with the filter box:



Version History

 * Version 2.0 (2013-02-20)
 * User can now filter logs by title, and choose to show or hide actions performed by anonymous users, logged-in users, and viewer themselves. Database schema is also changed to improve filtering efficiency.


 * Version 1.0.2 (2012-01-06)
 * Add anonymous logging option.


 * Version 1.0.1 (2011-12-10)
 * Minor bug fix.


 * Version 1.0 (2011-11-02)
 * First version, with basic logging function and log view page. Logs can be filtered by user, action, namespace and date.

Download

 * Access Log 2.0 (newer version, for MediaWiki 1.18 - 1.20)
 * Access Log 1.0.2 (older version, for MediaWiki 1.15 - 1.18)

Requirements
The AccessLog extension has the following requirements (besides the MediaWiki versions specified in the extension box):


 * MySQL database servers are required; PostgreSQL and SQLite are not supported.
 * MediaWiki database administrator access (or other database role that has privileges for creating SQL functions).

Step by Step Instruction
Step 1: Download the archive file from the link above.

Step 2: Extract the downloaded archive to the extensions directory of your MediaWiki installation. For example (replace with the actual path to your MediaWiki installation):

Step 3: Add the following line to the bottom of  (before the trailing ?>, if it is present):

Step 4 (optional): Disable client side caching to make sure every page view request hits the server and thus gets logged. Set $wgCachePages to false in :

Step 5: Update the MediaWiki database by executing the update.php maintenance script.

Step 6: As an administrator (sysop) user, visit the page 'Special:AccessLog' in your MediaWiki installation. If everything went well you should see the AccessLog special page.

Step 7 (optional): By default, actions from anonymous users are ignored. To log actions from anonymous users, add the following line after the  statement of step 3:

Step 8 (optional): If you are using the Access Control Panel extension, the members of $wgAccessControlPanelAllowedGroup can also access the access log page. If you are not using that extension, but want to grant access privilege to non-sysop users, create a new user group. Add the following lines to. After that, add user(s) who are going to read the access log into 'ControlGroup' (or whatever name you chose for this group). For detailed steps, please visit Help:Assigning permissions.

Upgrading from older versions
Step 1: Download the newer version archive from the link above.

Step 2: Extract the downloaded archive to the extensions directory of your MediaWiki installation and replace the old version files. For example (replace with the actual path to your MediaWiki installation):

Step 3: Update the MediaWiki database by executing the update.php maintenance script.

Step 4 (optional): In the previous step, newly introduced columns are filled with NULL values for old entries. Because of that, old entries will not be displayed when the log filter is used. To apply filters for old entries, update the old entries (fill in the newly introduced columns) by executing the updateLogRecord.php maintenance script.

PostgreSQL
I'm using this extension with PostgreSQL. You may try it a your own risk. Just edit the SQL file, changig the data types to look like this:

CREATE TABLE /*$wgDBprefix*/tw_accesslog ( tw_log_id SERIAL,  -- Unique ID of log entry  tw_log_timestamp varchar NOT NULL DEFAULT '19700101000000',  -- timestamp of the action, in MediaWiki format  tw_log_user int DEFAULT NULL,  -- User ID of the action performer  tw_log_username varchar NOT NULL,  -- User name of the action performer  tw_log_namespace int DEFAULT NULL,  tw_log_title varchar NOT NULL,  -- Title of the page  tw_log_action varchar(32) NOT NULL,  -- Name of action  PRIMARY KEY (tw_log_id) ) /*$wgDBTableOptions*/;

CREATE INDEX ON tw_accesslog (tw_log_timestamp); CREATE INDEX ON tw_accesslog (tw_log_user,tw_log_timestamp); CREATE INDEX ON tw_accesslog (tw_log_namespace,tw_log_timestamp); CREATE INDEX ON tw_accesslog (tw_log_title,tw_log_namespace,tw_log_timestamp); = Remove eg Googlebot's = I was using the feature, but had annoying bots filling the access Log but needed the anonymous logging active Remove eg some of the disturbing mass of Googlebot's IP's out of the anonymous logging

Open

Allocate function insertLog( $userid, $username, $namespace, $title, $action ) 

Modify $dbw = wfGetDB( DB_MASTER ); $dbw->begin; $dbw->insert( 'tw_accesslog', $log_entries_arr ); $dbw->commit; into // Remove eg some of the Googlebot's out of the anonymous logging // Make sure you add the dot after the 3 ip bloc's to assign the range xxx.xxx.xxx.1--255 $wfRobotsIP = array('66.249.77.','66.249.79.'); $robot_detected = false; foreach($wfRobotsIP as $value){ if( strpos( $username,$value)!== false ) { # NOK,is an Bot. Skip the bot from the log $robot_detected = true; } }	if ( $robot_detected !== true ) { $dbw = wfGetDB( DB_MASTER ); $dbw->begin; $dbw->insert( 'tw_accesslog', $log_entries_arr ); $dbw->commit; }