daz9e / laravel-log-compressor
Lets you compress .log files in your laravel app by command or schedule.
1.3
2025-07-28 06:50 UTC
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: 2026-03-28 08:23:47 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