我在日志中发现了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?
最佳答案
在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 [] []