php – 在laravel 5.3中截断的错误日志
我在laravel 5.3日志中有这个条目
为什么它会截断一条重要的错误信息?现在我无法弄清楚出了什么问题…… 解决方法
截断是由Guzzle库完成的.它仅显示响应的前120个字符.我假设这是因为回复可能会很长.
如果您想查看完整的消息,您应该能够自定义如何处理guzzle异常. 将app / Exceptions / Handler.php中的report()方法更新为: public function report(Exception $exception) { // this is from the parent method if ($this->shouldntReport($exception)) { return; } // this is from the parent method try { $logger = $this->container->make(PsrLogLoggerInterface::class); } catch (Exception $ex) { throw $exception; // throw the original exception } // this is the new custom handling of guzzle exceptions if ($exception instanceof GuzzleHttpExceptionRequestException) { // get the full text of the exception (including stack trace),// and replace the original message (possibly truncated),// with the full text of the entire response body. $message = str_replace( rtrim($exception->getMessage()),(string) $exception->getResponse()->getBody(),(string) $exception ); // log your new custom guzzle error message return $logger->error($message); } // make sure to still log non-guzzle exceptions $logger->error($exception); } 注意:这是在report方法中完成的,因此它只会影响写入日志的内容.如果将异常转储到终端或浏览器,它仍将显示截断的消息. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |