如何从laravel日志文件中找到错误的路由(Laravel 5.4)

时间:2017-12-15 02:00:07

标签: laravel laravel-5

感谢laravel.log文件,我们可以从中找到有问题的源代码行和变量。

然而,有时我需要完整的路线。我无法生成错误,因为特定路由实例会发生错误。

示例错误日志如下。但它并没有说出路线实例的任何内容。我怎么能得到它?

[2017-12-14 20:52:39] production.ERROR: ErrorException: Undefined variable: posts_recommends in /usr/share/nginx/html/my_site/storage/framework/views/ef89cba27180cabe.php:2
Stack trace:
#0 /usr/share/nginx/html/my_site/storage/framework/views/ef89cba27180cabe.php(2): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined varia...', '/usr/share/ngin...', 2, Array)
#1 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(42): include('/usr/share/ngin...')
#2 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/usr/share/ngin...', Array)
#3 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/View.php(137): Illuminate\View\Engines\CompilerEngine->get('/usr/share/ngin...', Array)
#4 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/View.php(120): Illuminate\View\View->getContents()
#5 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/View.php(85): Illuminate\View\View->renderContents()
#6 /usr/share/nginx/html/my_site/storage/framework/views/3d0c6734f352f06c3beea5ef32112a268a03fd48.php(185): Illuminate\View\View->render()
#7 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(42): include('/usr/share/ngin...')
#8 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/usr/share/ngin...', Array)
#9 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/View.php(137): Illuminate\View\Engines\CompilerEngine->get('/usr/share/ngin...', Array)
#10 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/View.php(120): Illuminate\View\View->getContents()
#11 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/View.php(85): Illuminate\View\View->renderContents()
#12 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Http/Response.php(38): Illuminate\View\View->render()
#13 /usr/share/nginx/html/my_site/vendor/symfony/http-foundation/Response.php(201): Illuminate\Http\Response->setContent(Object(Illuminate\View\View))
#14 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(615): Symfony\Component\HttpFoundation\Response->__construct(Object(Illuminate\View\View))
#15 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(572): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View))
#16 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#17 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#18 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#22 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#24 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#25 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#27 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#31 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#32 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#33 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#36 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(574): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#37 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(533): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#38 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(511): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#39 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#40 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#41 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#42 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#43 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#44 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#45 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#47 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#48 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#49 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#50 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#51 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#52 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#53 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#54 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#55 /usr/share/nginx/html/my_site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#56 /usr/share/nginx/html/my_site/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#57 {main}

1 个答案:

答案 0 :(得分:0)

您看到的错误与视图中使用变量posts_recommends有关(无法找到)。

您可以查找文件my_site/storage/framework/views/ef89cba27180cabe.php(视图的缓存版本)以查看受影响的视图,这将告诉您需要修复哪个实际视图文件。

您无需知道修复此错误的确切路线,因为它与您尝试渲染的视图相关。