Documentation

Installation

  1. Download the package from the Concrete CMS Marketplace
  2. Extract to your packages/ directory
  3. Navigate to Dashboard > Extend Concrete CMS
  4. Click Install next to Macareux Logs Cleaner

Basic Usage

The package provides a CLI command accessible through the Concrete CMS console:

concrete/bin/concrete5 md:logs:clear [options]

Default Behavior

⚠️ IMPORTANT: When executed without any options, the command will delete ALL logs from your database after prompting for confirmation:

concrete/bin/concrete5 md:logs:clear

This default behavior will:

  • Select all log entries from all channels
  • Include all log levels (debug, info, warning, error, critical, alert, emergency)
  • Include logs from all time periods (no date filtering)
  • Prompt for confirmation before deletion (unless --force flag is used)

Recommended: Always use at least one filter option (--channel, --days, or --level) to avoid accidentally deleting important logs. Better yet, run with --dry-run first to preview what will be deleted.

Available Options

Option Short Description
--channel -c Filter by specific log channel (e.g., system, application)
--days -d Delete logs older than specified days
--level -l Filter by log level(s), comma-separated (debug,info,warning,error)
--backup -b Create CSV backup before deletion
--dry-run Preview logs without deleting (default shows 10 entries)
--limit Number of entries to display in dry-run (0 = show all, default: 10)
--force -f Skip confirmation prompt

Common Examples

Preview what will be deleted (dry-run, default 10 entries):

concrete/bin/concrete5 md:logs:clear --channel=system --dry-run

Preview all logs that would be deleted:

concrete/bin/concrete5 md:logs:clear --days=30 --dry-run --limit=0

Preview 50 log entries:

concrete/bin/concrete5 md:logs:clear --level=debug --dry-run --limit=50

Delete logs older than 30 days:

concrete/bin/concrete5 md:logs:clear --days=30

Clear debug and info logs with backup:

concrete/bin/concrete5 md:logs:clear --level=debug,info --backup

Force clear all system logs (no prompt):

concrete/bin/concrete5 md:logs:clear --channel=system --force

Comprehensive cleanup with all options:

concrete/bin/concrete5 md:logs:clear --channel=application --days=90 --level=debug,info --backup

Automation with Cron

Schedule automatic log cleanup by adding to your crontab:

# Clear logs older than 30 days every Sunday at 2 AM
0 2 * * 0 /path/to/concrete/bin/concrete5 md:logs:clear --days=30 --force

Backup Configuration

Configure backup settings by creating application/config/md_logs_cleaner/settings.php:

<?php
return [
    'backup' => [
        'path' => 'log_backups',
        'storage_location_id' => 1, // Optional: defaults to default storage
        'visibility' => 'private', // Optional: 'public' or 'private'
    ],
];

Best Practices

  1. Always test with dry-run first: Use --dry-run to preview deletions
  2. Create backups for production: Use --backup flag before deleting important logs
  3. Start conservatively: Begin with longer retention periods (e.g., 90 days)
  4. Monitor storage impact: Check database size before and after cleanup
  5. Schedule regular cleanups: Implement automated maintenance via cron
  6. Document your policy: Keep records of your log retention policies

Troubleshooting

Q: Backup creation fails A: Ensure backup path is configured in application/config/md_logs_cleaner/settings.php and the storage location is writable.

Q: Command times out on large log tables A: The package uses batch processing to handle millions of records. Increase PHP max_execution_time if needed, or run multiple passes with narrower filters.

Q: How do I know which channels exist? A: Run with --dry-run without filters to see a sample of all logs with their channels.

Q: Can I undo a deletion? A: No, create a backup first using the --backup flag. Always preview with --dry-run before deleting.