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.
Pros:
LogCleaning, LogCleaned, LogFileCleaned) for extensibility (e.g., logging, notifications, or auditing).--memory-efficient flag and configurable thresholds.Cons:
laravel.log). Custom log handlers (e.g., Monolog, Syslog) or external log storage (e.g., ELK, S3) are out of scope.storage/logs/ by default).storage/logs/ paths.LogCleaner::clear()) enables integration into custom scripts or middleware.--no-lock flag).storage/logs/ (standard Laravel requirement).max_backups).--memory-efficient).--dry-run in CI/CD to validate operations.composer require jiordiviera/laravel-log-cleaner
php artisan vendor:publish --provider="JiordiViera\LaravelLogCleaner\LaravelLogCleanerServiceProvider" --tag="log-cleaner-config"
--dry-run and adjust config as needed.php artisan log:clear.// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('log:clear --days=30 --backup')
->dailyAt('2:00');
}
config/log-cleaner.php for default values.php artisan log:clear --dry-run to validate.max_backups.config/log-cleaner.php (no scattered logic).storage/logs/ permissions (chmod -R 775 storage/logs/).--no-lock for scripted operations or adjust locking.timeout.min_free_disk_space_mb and backup retention.--verbose.LogCleaning, LogCleaned).--memory-efficient for files >50MB (configurable via memory_threshold).--no-lock if needed).--compress).--memory-efficient).compression.level).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Permission denied on logs | Command fails silently | Ensure storage/logs/ is writable by web server. |
| Disk full during backup | Backup fails, logs remain unclean | Set min_free_disk_space_mb conservatively. |
| File locked by another process | Command hangs or fails | Use --no-lock or adjust locking.timeout. |
| Corrupted log file | Command crashes | Test with --dry-run first; exclude problematic files. |
| Laravel event system disabled | Events not dispatched | Enable events in config or use facade directly. |
| PHP memory |
How can I help you explore Laravel packages today?