コード例 #1
0
  @Test
  public void hyphenReplacesContentSizeForEmptyResponses() throws Exception {
    request.remoteIp("192.168.0.1").method(DELETE).uri("/logout");
    apacheCommonLogger.connectTo(
        new Application() {
          public void handle(Request request, Response response) throws Exception {
            response.body("");
            response.status(NO_CONTENT);
          }
        });

    apacheCommonLogger.handle(request, response);

    logRecords.assertEntries(contains(containsString("\"DELETE /logout HTTP/1.1\" 204 -")));
  }
コード例 #2
0
 public void handle(Request request, Response response) throws Exception {
   forward(request, response);
   String msg =
       String.format(
           COMMON_LOG_FORMAT,
           request.remoteIp(),
           "-",
           currentTime(),
           request.method(),
           request.uri(),
           request.protocol(),
           response.statusCode(),
           contentLengthOrHyphen(response));
   logger.info(msg);
 }