如何更改laravel log stackdepth

时间:2017-01-27 09:37:12

标签: laravel

是否有办法限制laravel日志中的stackdepth 通常我只对第一行感兴趣 使用tail -f,Pipeline.php行可以消除真正的错误 这是一个例子:

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_id' in 'field list' (SQL: insert into `results` (`)' in vendor/laravel/framework/src/Illuminate/Database/Connection.php:647                     
Stack trace:                                                                                                                                                            
#0 vendor/laravel/framework/src/Illuminate/Database/Connection.php(607): Illuminate\Database\Connection->runQueryCallback('insert into `re...', Array, Object(Closure))                                                                                                                                    
#1 vendor/laravel/framework/src/Illuminate/Database/Connection.php(450): Illuminate\Database\Connection->run('insert into `re...', Array, Object(Closure))                                                                                                                                                 
#2 vendor/laravel/framework/src/Illuminate/Database/Connection.php(404): Illuminate\Database\Connection->statement('insert into `re...', Array)                                                                                                                                                            
#3 vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2180): Illuminate\Database\Connection->insert('insert into `re...', Array)                                                                                                                                                           
#4 routes/web.php(262): Illuminate\Database\Query\Builder->insert(Array)                                                           
#5 vendor/laravel/framework/src/Illuminate/Routing/Route.php(190): Illuminate\Routing\Router->{closure}(Object(Illuminate\Http\Request))                                                                                                                                                                   
#6 vendor/laravel/framework/src/Illuminate/Routing/Route.php(163): Illuminate\Routing\Route->runCallable()                         
#7 vendor/laravel/framework/src/Illuminate/Routing/Router.php(559): Illuminate\Routing\Route->run()                                
#8 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))                                                                                                                                              
#9 vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))                                                                                                                       
#10 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))                                                                                                                         
#11 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))                                                                                                                                         
#12 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))                                                                                                                 
#13 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))                                                                                                                    
#14 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))                                                                                                                                         
#15 vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))                                                                                                                     
#16 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))                                                                                                                        
#17 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))                                                                                                                                         
#18 vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))                                                                                                                            
#19 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))                                                                                                                               
#20 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))                                                                                                                                         
#21 vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))                                                                                                               
#22 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))                                                                                                                  
#23 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))                                                                                                                                         
#24 vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))                                                                                                                           
#25 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))   

1 个答案:

答案 0 :(得分:2)

您可以更改

public function report(Exception $exception)
    {
        parent::report($exception);
    }

public function report(Exception $exception)
    {
        if ($this->shouldntReport($exception)) {
            return;
        }

        try {
            $logger = $this->container->make(\Psr\Log\LoggerInterface::class);
        } catch (Exception $ex) {
            throw $exception; // throw the original exception
        }

        $logger->error($exception->getMessage());
    }

在你的“app / Exceptions / Handler.php”