Looking to hire Laravel developers? Try LaraJobs

laravel-log-compressor maintained by daz9e

Description
Lets you compress .log files in your laravel app by command or schedule.
Author
Last update
2026/10/08 16:22 (dev-master)
License
Links
Downloads
576

Comments
comments powered by Disqus

Laravel Log Compressor

tests Packagist Version License

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 .log files in storage/logs (including subdirectories) that are older than days, counted from the newest log file. The original file is removed only after the .gz is written successfully.
  • Deletes .log.gz archives older than logging.channels.daily.days (default 14).
  • 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