这是错误:
[2015-07-01 00:12:19] production.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:148
Stack trace:
#0 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1054): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1022): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/vhosts/mywebsite.com/laravel/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/vhosts/mywebsite.com/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#10 /var/www/vhosts/mywebsite.com/httpdocs/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []
我完全不知道这个错误来自哪里,而且我已经厌倦了加载日志。
答案 0 :(得分:3)
您可以添加异常处理程序,检查异常是否是Symfony\Component\HttpKernel\Exception\NotFoundHttpException
的实例,如果是,请记录请求路径,以便知道它被击中的路由。
App::error(function(Exception $exception, $code) {
if ($exception instanceof Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
Log::error('Invalid Route', ['route' => Request::path()]);
}
});
我把它放在app/start/global.php
。
然后下次发生这种情况时,请检查laravel.log
中的Invalid Route
字样,它会让您知道发生了什么。请记住,甚至可能不是您的用户正在这样做。我已经在制作过程中做了类似的事情,并且通常每天都会遇到一些这样的错误,因为机器人只是随机寻找可以访问的东西。