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

1.3 2025-07-28 06:50 UTC

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 to LOG_COMPRESS_DAYS in .env or 2 days.

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: 14 days).

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