An artisan command to clear laravel log files
Install via composer
composer require hedii/artisan-log-cleaner
Add it to your providers array in config/app.php
:
Hedii\ArtisanLogCleaner\ArtisanLogCleanerServiceProvider::class
Run this command to clear all log files in the log directory (storage/logs
):
php artisan log:clear
Run this command to clear all log files except the last one in the log directory (storage/logs
):
php artisan log:clear --keep-last
Run this command to clear all log files except the specified files in the option. Specify file name without extension. Can be combined with --keep-last
option.
php artisan log:clear --keep="keptLog"
Add this to the App\Console\Kernel schedule method to ensure daily cleanup of old log files
$schedule->command('log:clear --keep-last')->daily();
composer test
hedii/artisan-log-cleaner is released under the MIT Licence. See the bundled LICENSE file for details.