daz9e / laravel-log-compressor
Lets you compress .log files in your laravel app by command or schedule.
Installs: 215
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/daz9e/laravel-log-compressor
Requires
- php: ^7.4|^8.0
- laravel/framework: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
This package is auto-updated.
Last update: 2025-12-28 07:49:08 UTC
README
Usage
Run the command to compress log files older than a specified number of days and delete old compressed logs.
php artisan logs:compress [days]
days(optional): Number of days to keep logs uncompressed. Defaults toLOG_COMPRESS_DAYSin.envor2days.
Example
php artisan logs:compress 5
Compresses logs older than 5 days and deletes .gz files older than 14 days (configurable in config/logging.php).
Configuration
In config/logging.php:
compress_days: Days to keep logs uncompressed (default:2). Override via.env:LOG_COMPRESS_DAYS=5
logging.channels.daily.days: Retention period for compressed logs (default:14days).
Scheduling
Scheduled to run daily in routes/console.php:
Schedule::command('logs:compress')->daily();
Ensure the Laravel scheduler is set up:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1