aaLogWP Documentation

This page documents the WordPress plugin which gives developers access to the aaLog class from WordPress code.

The documentation explaining what aaLog is, and how to write aaLog calls is on the aaLog documentation page.

Download or clone the plugin from the GitHub page.

aaLogWP integrates the PHP aaLog logging class with WordPress. This allows WordPress developers to easily view the values of given variables, or track which branches of code their execution took; all without polluting their web page output with logging messages. All aaLog messages are written to a text file.

Installing aaLogWP

aaLogWP is installed in the usual manner. A directory called aalogwp is placed in the wp-content/plugins directory. The plugin is then activated from the wp-admin/plugins page. Before you can use the aaLogWP plugin, you must set permissions on the wp-content/aalogwp/logs directory so the web server can write to it. The easy way is to set permissions on the directory to 777. The proper way is to set the owner and group to the same as the web server’s process. (For the time being, addressing how to do this is beyond the scope of this article.)

If the plugin cannot write to the aalogwp/logs directory, an error message will appear on admin pages:

Plugin aaLogWP couldn’t write to the log directory {$logdir}. Probably a permissions issue.

There is an options page at Settings | aaLog Options, and it looks like so:

aaLog Settings 2014-06-07 21-59-58


By default, the logging mode is off. Turning it on causes a cookie to be created on the user’s browser. This tells aaLog to produce logging messages. Since the cookie turns on the logging, the logging is only in effect for users who have the cookie. So you can safely use aaLog, even on sites under load.

Also note, that the cookie has a built-in nonce. So a malicious user couldn’t arbitrarily spoof the cookie. (The nonce here is used only as a randomly generated string, and is not time-limited.)

The default filename also has a nonce. You can override the filename, either changing the aalog part, or removing the nonce part, or both. A secret logfile name insures malicious users sharing your server won’t be able to read your logfile. Please note the plugin will add a .log extension to the filename you specify.

You can regenerate the cookie, changing the nonce, by pressing the Regenerate Cookie button. You may want to do this if you’d previously set the cookie on a user’s browser for some testing, and now want to disable that user’s ability to generate log messages. Regenerating the cookie effectively turns off logging. So you’ll have to switch it back on if you want to continue generating logging messages.

There is also a Regenerate Filename button. This changes the filename back to the default aalog-<nonce>, and produces a new nonce. You may want to do this if you suspect that despite your best efforts, someone is peeking inside your logfile. Or perhaps, just because it’s time to change the nonce.

aalog_init Action

The aalog_init action is fired at the beginning of the init action. It’s handy for firing off logging messages at the beginning of a request. I use it to add demarcation lines to my logfile, showing where a request begins, and throw in the server and request arrays for good measure.

Here’s a brief custom plugin which uses the aalog_init action:

Plugin Name: MyCustomPlugin
Plugin URI: http://notoriouswebmaster.com/
Description: Custom plugin. Not for distribution.
Version: 1.0.0
Author: A. Alfred Ayache
Copyright: 2014, The Last Byte, inc.

class aaaCustomPlugin {
	public function __construct() {

		add_action('aalog_init', array(&$this, 'aalog_init'));

	public function aalog_init() {
		global $oLog;


$aaaCustom = new aaaCustomPlugin();

Uninstalling aaLogWP

Deactivating the aaLogWP plugin while you have calls to $oLog will generate errors on the page output. So to deactivate and uninstall the plugin, first remove all calls to $oLog. Even deactivating the plugin will cause issues with outstanding calls to $oLog, since the object won’t have been created.


You’re welcome to ask questions and leave comments. No promises about how long I’ll take to reply, if at all. I’ve been using the aaLog class for 8 years now, and I’m still enhancing it on an occasional basis; so chances are good I’ll keep updating it, especially if users make good suggestions.

If you’re looking for quicker turn-around on your support requests, I am available for some contract work. Fair warning: I have a full-time job which takes priority.

Thank You

Thank you for your interest in aaLogWP. I hope you find it as useful as I have.

One thought on “aaLogWP Documentation

  1. Hi,

    Found your plugin on the repository and it seems to be exactly what I was looking for, i.e. allowing me to log only those users I want to and to a flat file. Alas, I’m a code idiot, in other words I can read but not write. I tried to set up under Genesis a simple function:

    $aaaCustom = new aaaCustomPlugin();
    $oLog->setCookie(); ?>


    and get the error
    ========> fatal error: Call to a member function setCookie() on a non-object in /home/repbar/public_html/2014/wp-content/uploads/dynamik-gen/theme/custom-hook-boxes.php on line 72

    Can you please give me a pointer how to invoke the log write when the plugin is installed?


    Take care and have a great end-of-summer


    From Finland 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *