### Question:
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, cause); } } HttpErrorStatusCauseLogger(HttpMessageFormatter formatter); @Override void proxyErrorOccurred(HttpResponseStatus status, Throwable cause); @Override void proxyErrorOccurred(LiveHttpRequest request, InetSocketAddress clientAddress, HttpResponseStatus status, Throwable cause); @Override void proxyErrorOccurred(Throwable cause); @Override void proxyWriteFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause); @Override void proxyingFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause);  }### Answer:
@Test public void logsThrowables() { Exception exception = new Exception("This is just a test"); httpErrorStatusCauseLogger.proxyErrorOccurred(INTERNAL_SERVER_ERROR, exception); assertThat(loggingTestSupport.log(), hasItem( loggingEvent( ERROR, "Failure status=\"500 Internal Server Error\"", "java.lang.Exception", "This is just a test"))); }
@Test public void logsThrowablesWithStatus5xxExcluding500WithoutStackTrace() { Exception exception = new Exception("This is just a test"); httpErrorStatusCauseLogger.proxyErrorOccurred(BAD_GATEWAY, exception); assertThat(loggingTestSupport.log(), hasItem( loggingEvent( ERROR, "Failure status=\"502 Bad Gateway\", exception=\"java.lang.Exception.*This is just a test.*\""))); }
@Test public void logsInternalServerErrorWithRequest() { LiveHttpRequest request = LiveHttpRequest.get("/foo").build(); Exception exception = new Exception("This is just a test"); httpErrorStatusCauseLogger.proxyErrorOccurred(request, InetSocketAddress.createUnresolved("localhost", 80), INTERNAL_SERVER_ERROR, exception); assertThat(loggingTestSupport.log(), hasItem( loggingEvent( ERROR, "Failure status=\"500 Internal Server Error\" during request=" + FORMATTED_REQUEST + ", clientAddress=localhost:80", "java.lang.Exception", "This is just a test"))); }
@Test public void logsOtherExceptionsWithoutRequest() { LiveHttpRequest request = LiveHttpRequest.get("/foo").build(); Exception exception = new Exception("This is just a test"); httpErrorStatusCauseLogger.proxyErrorOccurred(request, InetSocketAddress.createUnresolved("127.0.0.1", 0), BAD_GATEWAY, exception); assertThat(loggingTestSupport.log(), hasItem( loggingEvent( ERROR, "Failure status=\"502 Bad Gateway\", exception=\"java.lang.Exception.*This is just a test.*\""))); }