diff --git a/src/Service/ActivityPub/ApHttpClient.php b/src/Service/ActivityPub/ApHttpClient.php index fcb8e5440..0c58ba7fa 100644 --- a/src/Service/ActivityPub/ApHttpClient.php +++ b/src/Service/ActivityPub/ApHttpClient.php @@ -338,17 +338,21 @@ private function logRequestException(?ResponseInterface $response, string $reque } } - // Often 400, 404 errors just return the full HTML page, so we don't want to log the content of them - $this->logger->error('{type} get fail: {address}, ex: {e}: {msg}', [ + // Often 400, 404 errors just return the full HTML page, so we don't want to log the full content of them + // We truncate the content to 200 characters max. + $this->logger->error('{type} get fail: {address}, ex: {e}: {msg}. Truncated content: {content}', [ 'type' => $requestType, 'address' => $requestUrl, 'e' => \get_class($e), 'msg' => $e->getMessage(), + 'content' => substr($content, 0, 200) ?? 'No content provided', ]); - // Therefore, we only log the content in debug log mode - $this->logger->debug('Response body content: {content}', [ - 'content' => $content ?? 'No content provided', - ]); + // And only log the full content in debug log mode + if ($content) { + $this->logger->debug('Full response body content: {content}', [ + 'content' => $content, + ]); + } throw $e; }