Laravel by default doesn't report these:
//src/Illuminate/Foundation/Exceptions/Handler.php
/**
* A list of the internal exception types that should not be reported.
*
* @var array
*/
protected $internalDontReport = [
AuthenticationException::class,
AuthorizationException::class,
HttpException::class,
HttpResponseException::class,
ModelNotFoundException::class,
SuspiciousOperationException::class,
TokenMismatchException::class,
ValidationException::class,
];
Now, you can in app/Exceptions/Handler.php
you can have that array imported then remove the HttpException
and ModelNotFoundException
, or whichever Exception you want like so
...
// app/Exceptions/Handler.php
protected $internalDontReport = [
AuthenticationException::class,
AuthorizationException::class,
// HttpException::class,
HttpResponseException::class,
// ModelNotFoundException::class,
SuspiciousOperationException::class,
TokenMismatchException::class,
ValidationException::class,
];
...
ModelNotFoundException
is when you have a route like route::get('/articles/{article}','ArticleController@single');
and have that assigned in the controller as function single(Article $article)
and $article
is not found.
Pick what to keep and what to comment out.
Second approach is to do this in the report
method in the same Handler.php
file
/**
* Report or log an exception.
*
* @param \Exception $exception
*
* @return void
* @throws Exception
*/
public function report(Exception $exception)
{
# Report 404
if ($exception instanceof NotFoundHttpException || $exception instanceof ModelNotFoundException) {
# Log as warning
Log::warning('Your message');
# Or Log as info
Log::info($exception);
// ...
}
....
}
You can find more about loggin in this Laravel Logging
And Laravel Errors
Hope this answers your question!