How to empty log files data before adding new contents to it. Using Monolog for saving all logs inside
storage/app/logs/*
How to empty log files data before adding new contents to it. Using Monolog for saving all logs inside
storage/app/logs/*
Copyright © 2021 Jogjafile Inc.
You can use
rmcommand through ssh to remove all logs:rm storage/logs/laravel-*.log. Use*as wildcard to remove all logs if they have suffixes.Or you can add custom code within Controller method only for admins of app:
Or create a console command. Depending on version, below 5.3 use for example:
php artisan make:console logsClear --command=logs:clearFor versions 5.3 and above
php artisan make:command logsClearadd signature within command class if it doesn't exist.
protected $signature = 'logs:clear';Add your class in Console/Kernel.php, in protected $commands array ( note that your code varies upon customization for your app):
You should add then custom code in
handle()of logsClear classThen run
php artisan logs:clearcommand