1-
Route::get('testing', function(){
throw new \Exception('Check');
});
2-
In Terminal run this command to catch the exception with name Check
php artisan tail --only=Check
3-
Commands
routes/console.php
Artisan::command('tail {file=storage/logs/laravel-2024-09-24.log : A path to the file being tailed.}
{--only= : Grep the output for a specific string.}', function () {
$file = $this->argument('file');
$only = $this->option('only');
$command = 'tail -f "' . $file . '"';
if ($only) {
$command .= ' | grep "' . $only . '"';
}
$process = Process::fromShellCommandline($command)
;
$process->setTty(true);
$process->setTimeout(null);
$process->run(function ($type, $buffer) {
echo $buffer;
});
});