Skvare Logger provides a lightweight logging utility for CiviCRM that allows developers to write structured logs into separate, monthly-rotated log files. These logs are stored in the same directory used by CiviCRM for configuration and logs, but remain independent from core CiviCRM error logging.
This is useful for:
- Debugging specific features (mailings, payments, integrations)
- Auditing background jobs or cron processes
- Capturing structured debug output without polluting the main CiviCRM logs
- Singleton-based logger (
CRM_Logger) - Separate log files per feature/type
- Automatic monthly rotation (
YYYYMM) - Logs stored in CiviCRM
ConfigAndLogdirectory - Supports web and CLI execution
- Optional IP address logging
- Captures calling function, file, and line number
-
Place the extension in your CiviCRM extensions directory:
com.skvare.logger -
Enable the extension from:
- Administer » System Settings » Extensions
No additional configuration is required.
$logger = CRM_Logger::singleton();
$logger->write('mailing', print_r($params, TRUE));This will create (or append to) a file similar to:
ConfigAndLog/mailing202512.log
CRM_Logger::singleton()->write('payment', 'Duplicate transaction detected');CRM_Logger::singleton()->write('cron', 'Job started', FALSE);Each log entry includes:
- Timestamp
- Unique request ID (if available)
- Calling function
- File name and line number
- IP address (optional)
- Custom message content
Example output:
Dec 9th 14:35:18 - 8f823a7d
- civicrm_api3_mailing_send, /CRM/Mailing/BAO/Mailing.php (412)
from 192.168.1.10
Array
(
[contact_id] => 123
[status] => sent
)
All log files are written to:
[CiviCRM ConfigAndLog Directory]
Example:
sites/default/files/civicrm/ConfigAndLog/
- Use meaningful log file names (
mailing,payment,cron,integration) - Avoid logging sensitive data (credit cards, passwords, tokens)
- Use
print_r($data, TRUE)orjson_encode()for structured data - Remove or reduce logging in production environments where appropriate
- Tested with CiviCRM 5.45+
- Compatible with Drupal, WordPress, and Joomla installs
- Safe for CLI, cron, and web requests
AGPL-3.0
Skvare Website: https://www.skvare.com