Skip to content

Instantly share code, notes, and snippets.

@ceilidhboy
Last active July 24, 2022 20:06
Show Gist options
  • Save ceilidhboy/4e806922f268c24150539506a8c029ca to your computer and use it in GitHub Desktop.
Save ceilidhboy/4e806922f268c24150539506a8c029ca to your computer and use it in GitHub Desktop.
Laravel Artisan command to clear the laravel.log file. Usage: php artisan log:clear
<?php
namespace App\Console\Commands\Log;
use Illuminate\Console\Command;
class ClearLogFile extends Command
{
protected $signature = 'log:clear';
protected $description = 'Clear the laravel.log file';
public function handle(): int
{
exec('echo "" > '.storage_path('logs/laravel.log'));
$this->info('laravel.log has been cleared');
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment