Laravel doesn’t log 404 errors by default. I want to change this behavior.
Most guides say to log it manually in the following block :
public function register(): void
{
$this->reportable(function (Throwable $e) {
// Handle 404 here
});
}
but it seems like 404 exceptions don’t even trigger this method for some reason.
Doing the following technically works but it’s tedious to put everywhere I need it :
try {
$model = User::findOrFail(99999);
} catch (ModelNotFoundException $e) {
Log::error($e);
throw $e;
}
I’m using Laravel 10.
What am I doing wrong ?