@Test public void testTimestampFormat() throws Exception { String date = "\\d{2}/\\w{3}/\\d{4}"; String time = "\\d{2}:\\d{2}:\\d{2}"; String timezone = "(-|\\+)\\d{4}"; String regex = date + ":" + time + " " + timezone; DateFormat dateFormat = HttpRequestLogFormatter.dateFormat; String timestamp = dateFormat.format(SystemTime.asDate()); assertTrue("DateFormat should be \"dd/mon/yyyy:HH:mm:ss Z\"", timestamp.matches(regex)); }
public String format(HttpServletRequest request, int httpStatus, int contentLength) { StringBuffer line = new StringBuffer(); line.append(request.getRemoteAddr()); line.append(" - "); line.append(request.getRemoteUser()); line.append(" ["); line.append(dateFormat.format(SystemTime.asDate())); line.append("] \"").append(request.getMethod()); line.append(" ").append(request.getRequestURI()); line.append(" ").append(request.getProtocol()); line.append("\" ").append(httpStatus); line.append(" ").append(contentLength); return line.toString(); }
HttpRequestLogFormatter { public String format(HttpServletRequest request, int httpStatus, int contentLength) { StringBuffer line = new StringBuffer(); line.append(request.getRemoteAddr()); line.append(" - "); line.append(request.getRemoteUser()); line.append(" ["); line.append(dateFormat.format(SystemTime.asDate())); line.append("] \"").append(request.getMethod()); line.append(" ").append(request.getRequestURI()); line.append(" ").append(request.getProtocol()); line.append("\" ").append(httpStatus); line.append(" ").append(contentLength); return line.toString(); } }
HttpRequestLogFormatter { public String format(HttpServletRequest request, int httpStatus, int contentLength) { StringBuffer line = new StringBuffer(); line.append(request.getRemoteAddr()); line.append(" - "); line.append(request.getRemoteUser()); line.append(" ["); line.append(dateFormat.format(SystemTime.asDate())); line.append("] \"").append(request.getMethod()); line.append(" ").append(request.getRequestURI()); line.append(" ").append(request.getProtocol()); line.append("\" ").append(httpStatus); line.append(" ").append(contentLength); return line.toString(); }  }
HttpRequestLogFormatter { public String format(HttpServletRequest request, int httpStatus, int contentLength) { StringBuffer line = new StringBuffer(); line.append(request.getRemoteAddr()); line.append(" - "); line.append(request.getRemoteUser()); line.append(" ["); line.append(dateFormat.format(SystemTime.asDate())); line.append("] \"").append(request.getMethod()); line.append(" ").append(request.getRequestURI()); line.append(" ").append(request.getProtocol()); line.append("\" ").append(httpStatus); line.append(" ").append(contentLength); return line.toString(); }  String format(HttpServletRequest request, int httpStatus,
			int contentLength); }
HttpRequestLogFormatter { public String format(HttpServletRequest request, int httpStatus, int contentLength) { StringBuffer line = new StringBuffer(); line.append(request.getRemoteAddr()); line.append(" - "); line.append(request.getRemoteUser()); line.append(" ["); line.append(dateFormat.format(SystemTime.asDate())); line.append("] \"").append(request.getMethod()); line.append(" ").append(request.getRequestURI()); line.append(" ").append(request.getProtocol()); line.append("\" ").append(httpStatus); line.append(" ").append(contentLength); return line.toString(); }  String format(HttpServletRequest request, int httpStatus,
			int contentLength); static DateFormat dateFormat; }