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.
This major release introduces powerful new features for enterprise-grade log management in Laravel applications.
php artisan vendor:publish --tag="log-cleaner-config"Three new Laravel events for monitoring and reacting to cleaning operations:
LogCleaning - Dispatched before cleaning startsLogCleaned - Dispatched after cleaning completesLogFileCleaned - Dispatched for each file cleaned--no-lock, --no-events10 new exception classes for precise error handling:
InvalidDaysExceptionNoLogFilesExceptionInvalidLogLevelExceptionInvalidPatternExceptionPermissionExceptionBackupExceptionDiskSpaceExceptionFileLockExceptionZlibExceptionLogCleanerException (base exception)PHP: 8.2+
Laravel: 10.x, 11.x, 12.x
# Update to v2.2.0
composer require jiordiviera/laravel-log-cleaner:^2.2
# (Optional) Publish the new configuration file
php artisan vendor:publish --tag="log-cleaner-config"
Breaking Changes: None - All changes are backwards compatible.
Thanks to all contributors and users of the package!
Full Changelog: https://github.com/jiordiviera/laravel-log-cleaner/compare/v2.1.0...v2.2.0
preg_last_error_msg()$ php artisan log:clear --days=30 --dry-run
[DRY RUN] Would remove 150 lines from laravel.log
[DRY RUN] Estimated space to free: 45.2 MB
See CHANGELOG.md for full details.
This release introduces significant performance improvements, memory optimization, and powerful new features for Laravel Log Cleaner.
| Option | Description |
|---|---|
--backup |
Create backup before cleaning |
--dry-run |
Preview changes without applying |
--level=LEVEL |
Filter by log level (ERROR, WARNING, INFO, DEBUG) |
--pattern=REGEX |
Custom date pattern matching |
--compress |
Compress old logs instead of deleting |
--memory-efficient |
Force memory-efficient processing |
Continue using v1.x for compatibility:
composer require jiordiviera/laravel-log-cleaner:^1.0
Update your PHP and Laravel versions:
composer require jiordiviera/laravel-log-cleaner:^2.0
# Preview changes (dry run)
php artisan log:clear --days=30 --dry-run
# Create backup and compress old logs
php artisan log:clear --days=30 --backup --compress
# Filter by log level
php artisan log:clear --days=0 --level=ERROR
# Custom date pattern
php artisan log:clear --days=30 --pattern="/^(\d{4}-\d{2}-\d{2})/"
# Complete workflow with all safety features
php artisan log:clear --days=30 --backup --compress --level=ERROR --dry-run
This release addresses community feedback and provides a solid foundation for future enhancements. Thank you to all contributors and users who helped make this release possible!
Full Changelog: https://github.com/jiordiviera/laravel-log-cleaner/compare/v1.0.4...v2.0.0
How can I help you explore Laravel packages today?