RestApiServlet: Include formatted cause into log on internal server error

If there is an exception that is caused by a temporary error RetryHelper
takes care to retry the request for a short time. Most of the time this
makes the request be successful, however sometimes the temporary error
persists for the time of the retry, in which case RetryHelper will throw
the exception and RestApiServlet will log it and return '500 Internal
Server Error'.

When looking at the logs of internal server errors one cannot see if the
exception had triggering retries and timed out or if it was thrown
without retries. This distinction is important if you investigate
internal server errors. If there is an internal server error that is
caused by a temporary issue, you wonder if retrying for it should be
added or if retrying was already in place but didn't help. This
information can be made available in the logs by including the formatted
cause, since all exceptions which trigger retries have defined a
distinguishable formatted cause.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Iac345839b8fc4791b58aeaa4a0b785bb8c2e7b31
diff --git a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
index f30fefa..722955c 100644
--- a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
+++ b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
@@ -1799,13 +1799,15 @@
     return replyError(req, res, status.statusCode(), msg.toString(), err);
   }
 
-  private static long replyInternalServerError(
+  private long replyInternalServerError(
       HttpServletRequest req,
       HttpServletResponse res,
       Throwable err,
       ImmutableList<String> userMessages)
       throws IOException {
-    logger.atSevere().withCause(err).log("Error in %s %s", req.getMethod(), uriForLogging(req));
+    logger.atSevere().withCause(err).log(
+        "Error in %s %s: %s",
+        req.getMethod(), uriForLogging(req), globals.retryHelper.formatCause(err));
 
     StringBuilder msg = new StringBuilder("Internal server error");
     if (!userMessages.isEmpty()) {