Log Manager for Zen Cart 1.5.7 (and later)

Version 1.3.0

Current Support Thread at Zen Cart Forums: https://www.zen-cart.com/showthread.php?221939-Log-Manager-Support-Thread

What it does

Logs are good things, providing information that allows an after-the-fact analysis if something goes wrong … but they can start filling up your store's /logs directory if you don't keep a watch on them!

The Log Manager enables you to control how long you keep those .log files, inspecting each file's last-modified date, and then automatically removing (i.e. deleting) any files that are past their "expiration". There's also a setting to enable you to identify logs that you want to keep (e.g. zcInstall logs).

Once configured, Log Manager inspects your store's /logs directory, starting with v1.1.0, each time an admin successfully logs in to see if there are any candidates for removal … and, if found, removes them. Starting with v1.2.0, the plugin also creates and updates the file /logs/log_manager_removal.log to record its processing.

v1.3.0 introduces the site-specific capability to identify additional directories from which .log files can be automatically removed. To enable this feature, create a .php file in the /admin/includes/extra_datafiles sub-directory containing:

<?php
define('LOG_MANAGER_EXTRA_DIRECTORIES', 'directories-separated-by-a-semi-colon');
        

For example, to also remove .log files from the /includes/modules/payment/paypal/logs and /logs/edit_orders, you'd set the definition as:

<?php
define('LOG_MANAGER_EXTRA_DIRECTORIES', DIR_FS_CATALOG . 'includes/modules/payment/paypay/logs' . ';' . DIR_FS_LOGS . '/edit_orders');
        

This section identifies the procedure you'll use to install or remove the plugin for your Zen Cart.

There are no core-file overwrites required by Log Manager. Rename the YOUR_ADMIN folder to match your Zen Cart admin's folder name and then copy the plugin's files to your store's file-system:

  1. /YOUR_ADMIN/includes/auto_loaders/config.log_manager.php
  2. /YOUR_ADMIN/includes/init_includes/init_log_manager.php
  3. /YOUR_ADMIN/includes/languages/english/extra_definitions/log_manager_messages.php

Once installed, two additional configuration settings are added to your admin-console's Configuration->Logging:

Name Description
Log Manager: Days to Keep Identify the number of days to keep any .log file whose name doesn't match the Logs to Keep setting, based on a file's last-modified date. The default (0) disables the plugin's operation.
Log Manager: Files to Keep Identify the case-sensitive starting characters of any log-files that you want to keep, regardless of their age, using a comma-separated list. The default (zcInstall) keeps any files that match /logs/zcInstall*.log.

First, delete the files that were copied to your zen-cart installation's admin directories. Restore your backup up of then use your admin's Tools->Run SQL Patches to run the file /docs/log_manager/uninstall/log_manager_uninstall.sql.

This section identifies the files added or modified for this plugin as well as the plugin's change history.

The plugin provides the following files in its distribution zip-file.

  1. /YOUR_ADMIN/includes/auto_loaders/config.log_manager.php
  2. /YOUR_ADMIN/includes/init_includes/init_log_manager.php
  3. /YOUR_ADMIN/includes/languages/english/extra_definitions/log_manager_messages.php
  • v1.3.0, 2023-10-18:
    • CHANGE: Defer all processing until an admin has logged in.
    • CHANGE: Enable .log files to be removed from directories in addition to /logs.
  • v1.2.0, 2017-08-07:
    • CHANGE: Log removal check moved to a $_SESSION variable for the currently-logged-in admin.
    • CHANGE: Create/update /logs/log_manager_removal.log each time one or more files are removed.
  • v1.1.0, 2017-06-28, Log removal occurs now upon successful admin login.
  • v1.0.0, 2017-02-27, Initial release.