Search by

daz9e / laravel-log-compressor

daz9e

Lets you compress .log files in your laravel app by command or schedule.

Package info

github.com/daz9e/laravel-log-compressor

pkg:composer/daz9e/laravel-log-compressor

Statistics

Installs: 533

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.4 2026-10-08 14:22 UTC

This package is auto-updated.

Last update: 2026-10-08 14:39:35 UTC


README

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