Write to and view log files that have custom column labels and column count.

Custom Logs

When you use the core $log->save() method you can only save a single string of text. When you view the log in the core ProcessLogger the columns and their header labels are predetermined.

The Custom Logs module is different in that it lets you write and view log files with the number of columns and the column header labels you specify in the module configuration.


In the "Custom logs" textarea field, enter custom logs, one per line, in the format...

name: column label, column label, column label

...with as many comma-separated column labels as needed.

The log name must be a word consisting of only [-._a-z0-9] and no extension.

If you prefix a URL column label with {url} then the value in the column will be rendered as a link in the log viewer.

The date/time will automatically be added as the first column so you do not need to specify it here.

Writing to a custom log

Use the CustomLogs::save($name, $data, $options) method to save data to a custom log file.

$cl = $modules->get('CustomLogs');
$cl->save('my-log', $my_data);


$name Name of log to save to (word consisting of only [-._a-z0-9] and no extension).

$data An array of strings to save to the log. The number and order of items in the array should match the columns that are configured for the log.

$options (optional) Options for FileLog::save(). Normally you won't need to use this argument.

Example of use

Custom log definition in the module configuration:

visits: {url}URL, IP Address, User Agent, {url}Referrer

Saving data to the log:

$cl = $modules->get('CustomLogs');
$data = [
    $_SERVER['REQUEST_URI'] ?? '',
    $_SERVER['REMOTE_ADDR'] ?? '',
    $_SERVER['HTTP_USER_AGENT'] ?? '',
    $_SERVER['HTTP_REFERER'] ?? '',
$cl->save('visits', $data);

Viewing the resulting log in Setup > Logs > visits:


Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #532
    In the 532nd issue of ProcessWire Weekly we'll cover the latest core updates, check out a couple of brand-new third party modules, and more. Read on!
    Weekly.pw / 20 July 2024
  • Page List Custom Children module
    This simple module gives you the ability to customize the parent/child relationship as it appears in the admin page list, enabling child pages to appear under more than one parent.
    Blog / 28 June 2024
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani