daz9e / laravel-log-compressor
Lets you compress .log files in your laravel app by command or schedule.
1.4
2026-10-08 14:22 UTC
Requires
- php: ^7.4|^8.0
- laravel/framework: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.5|^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Gzips rotated Laravel log files (*-YYYY-MM-DD.log) and removes stale archives, so storage/logs stops eating your disk.
Installation
composer require daz9e/laravel-log-compressor
The service provider is auto-discovered, and the command is scheduled to run daily.
Usage
php artisan logs:compress [days]
- Compresses dated
.logfiles instorage/logs(including subdirectories) that are older thandays, counted from the newest log file. The original file is removed only after the.gzis written successfully. - Deletes
.log.gzarchives older thanlogging.channels.daily.days(default14). - Files without a date in the name, such as
laravel.log, are never touched.
Configuration
Optional keys in config/logging.php:
'compress_days' => env('LOG_COMPRESS_DAYS', 2), // days to keep logs uncompressed 'compress_schedule' => true, // set to false to disable the daily schedule
Archive retention reuses logging.channels.daily.days.
The daily run needs the Laravel scheduler:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Testing
composer install
composer test
License
MIT