Download the PHP package vocweb/laravel-log-compress without Composer
On this page you can find all versions of the php package vocweb/laravel-log-compress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-log-compress
Laravel Log Compress
Automatically compress daily-rotated Laravel log files to tar.gz archives with optional AES-256 password encryption. Reduce storage costs and simplify log management.
Features
- ✅ Auto-discover daily channels from logging configuration
- ✅ Smart file detection finds logs matching
{base}-YYYY-MM-DD.logpattern - ✅ Optional encryption AES-256-CBC via OpenSSL with PBKDF2 hashing
- ✅ Configurable retention skip logs newer than N days (default: 1)
- ✅ Safe deletion remove originals only after successful compression
- ✅ Auto-scheduled runs daily automatically, zero config needed
- ✅ Manual & scheduled Artisan command + custom scheduler support
- ✅ Error resilience continue processing on individual file errors, report all issues
- ✅ Secure passwords passed via environment variables, never exposed in process list
Requirements
| Component | Version |
|---|---|
| PHP | 8.1+ |
| Laravel | 10.x, 11.x, 12.x, 13.x |
| System Tools | tar, openssl (for encryption) |
Typical Linux/macOS installations have both tools. Windows requires GNU tar/openssl.
Installation
Via Composer
The package auto-registers via Laravel's package discovery.
Publish Configuration (Optional)
This creates config/log-compress.php in your Laravel project.
Configuration
Environment Variables
Add to your .env file:
Configuration File
Edit config/log-compress.php:
Usage
Manual Compression
Compress all eligible daily log files:
With Password Override
Encrypt archives with a specific password (overrides config):
Auto-Scheduled Execution
By default, the package automatically registers a daily scheduled task to compress logs. No manual setup required — just ensure your Laravel scheduler is running:
Configure Auto-Schedule
Via .env:
Manual Schedule (if auto-schedule is disabled)
If you set LOG_COMPRESS_AUTO_SCHEDULE=false, register the schedule manually:
Laravel 10 — app/Console/Kernel.php:
Laravel 11 — routes/console.php:
Laravel 12 / 13 — bootstrap/app.php:
How It Works
Discovery
- Scans all channels in
config/logging.php - Identifies channels with
driver: daily
Selection
- For each daily channel, finds log files:
- Pattern:
{base_path}-YYYY-MM-DD.log - Age: older than
older_than_dayssetting - Status: not already compressed
- Pattern:
Compression
- Creates tar.gz archive using system
tarcommand - If password configured: encrypts with OpenSSL AES-256-CBC
- Cleans up partial files on failure
Cleanup
- Deletes original log file (if
delete_after_compress: true) - Reports count of compressed files and any errors
Decrypting Encrypted Archives
If you encrypted logs with a password, decrypt them:
Example Workflow
Setup
Daily Operation
Retrieve Old Logs
Logging Configuration
Ensure you have a daily channel in config/logging.php:
Multiple daily channels are supported and will all be compressed.
Output & Status Codes
Successful Compression
Exit code: 0
No Files Found
Exit code: 0
With Errors
Exit code: 1
Security Notes
- Passwords: Never stored in config; use
.envfile only - Process safety: Passwords passed via environment variables, hidden from
ps aux - Encryption: AES-256-CBC with PBKDF2 (10,000 iterations), industry-standard
- Path safety: Real path resolution prevents directory traversal attacks
- File handling: Atomic operations; partial files cleaned up on failure
Troubleshooting
"tar: command not found"
- Install tar:
apt-get install tar(Debian/Ubuntu) orbrew install gnu-tar(macOS)
"openssl: command not found" (with encryption enabled)
- Install openssl:
apt-get install opensslorbrew install openssl
Permission denied errors
- Ensure Laravel process has read access to log files
- Ensure write access to log directory (for deletion)
Encrypted archives not decrypting
- Verify password: check
.envmatches password used at compression time - Use
-pass pass:your_passwordin openssl command (or-pass stdinto prompt)
License
MIT License - see LICENSE file for details.
Credits
Created by vocweb. Inspired by the need to manage large production log archives efficiently.
All versions of laravel-log-compress with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/process Version ^10.0|^11.0|^12.0|^13.0