You can also create custom artisan command.
First, run command php artisan make:command Log/ClearLogFile
to create custom command file.
Then, open file on Console/Commands/Log/ClearLogFile.php
(depends on you Laravel version, currently I'm using 5.5 version)
After that, you need to define the custom command code, take a look
// Define command name
protected $signature = 'log:clear';
// Add description to your command
protected $description = 'Clear Laravel log';
// Create your own custom command
public function handle(){
exec('echo "" > ' . storage_path('logs/laravel.log'));
$this->info('Logs have been cleared');
}
Then, you only need to run just like other php artisan command,
php artisan log:clear
Thanks, for @emotality answer
cat /dev/null > /app/storage/logs/laravel.log
- unix.stackexchange.com/questions/92384/how-to-empty-a-log-fileecho "" > /app/storage/logs/laravel.log
also works, and the most efficient istruncate -s 0 /app/storage/logs/laravel.log
. More info : unix.stackexchange.com/questions/88808/…rm storage\logs\laravel.log
if you know nothing else needs it, and it will reappear clean and new.