Laravel Log Cleaner is a package by Joost van Veen for keeping your log files small and tidy. While there are various ways to keep log file size tidy in production, this package uses the built-in Artisan console that you can run manually, via cron directly, or through the scheduler:
1$schedule2 ->command('logcleaner:run', [3 '--keeplines' => 5000,4 '--keepfiles' => 145 ])6 ->daily()7 ->at('01:00');
Log cleaner provides configurations you can set in your environment or override in the command. The main configuration features and console options include:
- Specify the number of files to keep
- Specify the number of lines to keep
- Exclude pattern to exclude file patterns from processing
- Log file trimming (enabled by default, configurable)
- Configurable file deletion enabled/disabled
Here are some console command examples from the readme that give you a nice visualization of how to use this console command:
1# Get info about the command and options 2php artisan logcleaner:run --help 3 4# Trim big log files and delete old log files 5php artisan logcleaner:run 6 7# Pass the number of lines to keep when trimming log files. Overrides the config setting. 8# This overrides the default set in config 9php artisan logcleaner:run --keeplines=1000010 11# Pass the number of files to keep when deleting old log files. Overrides the config setting.12# This overrides the default set in config13php artisan logcleaner:run --keepfiles=714 15# Run without actually cleaning any logs16php artisan logcleaner:run --dry-run
You can learn more about this package, get full installation instructions, and view the source code on GitHub.
0 comments:
Post a Comment
Thanks