error log truncated in laravel 5.3

The truncating is done by the Guzzle library. It only shows the first 120 characters of the response. I am assuming this is because responses could potentially be very long.

If you would like to see the full message, you should be able to customize how guzzle exceptions are handled.

Update the report() method in your app/Exceptions/Handler.php to something like:

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(\Psr\Log\LoggerInterface::class);
    } catch (Exception $ex) {
        throw $exception; // throw the original exception
    }

    // this is the new custom handling of guzzle exceptions
    if ($exception instanceof \GuzzleHttp\Exception\RequestException) {
        // 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);
}

Note: this is done in the report method, so it only affects what is written to the log. If the exception is dumped to the terminal or to the browser, it will still show the truncated message.


as alternative solution:

hotfix RequestException.php

ta_integration/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php

replace

$size = $body->getSize();
$summary = $body->read(120);
$body->rewind();

if ($size > 120) {

with for example:

    $size = $body->getSize();
    $summary = $body->read(999);
    $body->rewind();

    if ($size > 999) {

function

getResponseBodySummary


Because your request throws a Guzzle Exception, as a workaround, instead of calling $e->getMessage(), You can simply try:

$e->getResponse()->getBody()->getContents();

If you don't want to modify the report() method.

Worked nice for me.