错误日志在 Guzzle http 的 Laravel 中被截断

Par*_*lam 3 laravel guzzlehttp

Guzzle http 正在截断超过 120 个字符的异常,但我需要记录完整的异常消息。我怎样才能做到这一点?

我正在使用 Laravel 4.2.22。

Yam*_*raf 26

try {
    // whatever
} catch (\GuzzleHttp\Exception\RequestException $ex) {
     return $ex->getResponse()->getBody()->getContents(); 
     // you can even json_decode the response like json_decode($ex->getResponse()->getBody()->getContents(), true)    
}
Run Code Online (Sandbox Code Playgroud)


Yev*_*yev 8

Laravel 5 和 4 是一样的

    try {
        $response = $client->post($path, $params);
    } catch (\GuzzleHttp\Exception\RequestException $ex) {
        \Log::debug('error');
        \Log::debug((string) $ex->getResponse()->getBody());
        throw $ex;
    }
Run Code Online (Sandbox Code Playgroud)

如果你只是去$ex->getMessage(),你会 (truncated...) 到最后。