我在日志里找到了一个NotFoundHttpException。它看起来是这样的:
[2013-11-26 13:49:20] log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1429
Stack trace:
#0 /var/www/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1050): Illuminate\Routing\Router->handleRoutingException(Object(Symfony\Component\Routing\Exception\ResourceNotFoundException))
#1 /var/www/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1014): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(530): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#3 /var/www/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(506): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/myproject/public/index.php(49): Illuminate\Foundation\Application->run()
#5 {main} [] []这不会告诉您任何事情,只是浪费磁盘空间。
如何找到导致NotFoundHttpException的URI?
发布于 2013-11-26 22:22:14
在app/start/global.php中扩展App::error()
App::error(function(Exception $exception, $code)
{
if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException)
{
Log::error('NotFoundHttpException Route: ' . Request::url() );
}
Log::error($exception);
});现在,您将获得一个附加的日志条目,其中包含URL:
[2013-11-26 14:20:07] log.ERROR: NotFoundHttpException Route: http://myproject.net/asdfgsdfghsdfg [] []发布于 2017-08-09 18:58:49
您可以从日志文件中过滤404 (NotFoundHttpException)错误。
文件位置: app/start/global.php
App::error(function(Exception $exception, $errorCode)
{
$requestUrl = Request::fullUrl();
$userAgent = Request::header('user-agent');
if($errorCode != 404){
Log::error('Exception', array(
'errorCode' => $errorCode,
'requestUrl' => $requestUrl,
'userAgent' => $userAgent,
'context' => $exception,
));
}
return Response::view('error-page-path.error-404', array(), 404);
// Here "error-404" is a blade view file in "error-page-path" directory
});https://stackoverflow.com/questions/20219229
复制相似问题