jiordiviera/laravel-log-cleaner
Laravel Log Cleaner helps you purge old Laravel log files automatically. Configure retention rules and schedule cleanup via Artisan/cron to keep storage tidy, prevent large logs, and reduce disk usage with minimal setup.
Run composer require jiordiviera/laravel-log-cleaner to install. The package adds a single Artisan command: log:clear. For immediate use, run php artisan log:clear to clear all logs. For a production-safe first test, use php artisan log:clear --dry-run to preview what would be deleted without making changes.
Key starting points:
php artisan log:clear (clears all logs)--dry-run (safe testing)LogCleaner::clearAll() facade method# Weekly cleanup (30-day retention)
php artisan log:clear --days=30 --backup --compress
# Monthly archive (90-day retention)
php artisan log:clear --days=90 --backup --compress --level=ERROR
# In deployment scripts
php artisan log:clear --days=7 --no-events --memory-efficient
# Rotate logs with retention policy
php artisan log:clear --days=14 --backup --compress --level=WARNING
// In scheduled tasks
LogCleaner::clearOld(7, backup: true, compress: true);
// In custom commands
$cleaner = app(LogCleaner::class);
$cleaner->clearWithBackup(30);
// In service providers
app(LogCleaner::class)->clear(config('log.retention_days'));
--no-lock if running in environments where file locks may cause issues--memory-efficient for large log files (>100MB)min_free_disk_space_mb is configured appropriately--level=ERROR keeps only ERROR logs (removes all others)--dry-run to verify operations before executionstorage/logs/laravel.log.backup-*.gz for compressed backupsphp artisan event:listen JiordiViera\LaravelLogCleaner\Events\*backup['enabled'] = false to disable backups completelymemory_threshold for environments with constrained memorylocking['enabled'] = false for scripted operationsLogCleaning/LogCleaned for audit loggingLogCleaning eventLogCleaned event--memory-efficient--compressconfig/log-cleaner.phpHow can I help you explore Laravel packages today?