Add request latency (duration) to the httpd_log

In the sshd_log we have duration and in the httpd_log we do not. This
change fixes this asymmetry and adds useful info in the httpd_log.

Change-Id: I8483ea55d05f3fb4038e676df3301c2f96138fe1
This commit is contained in:
Saša Živkov
2018-10-16 17:24:21 +02:00
parent 4583cac8a8
commit 9e2f97c9ff
2 changed files with 5 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
protected static final String P_PROTOCOL = "Version";
protected static final String P_STATUS = "Status";
protected static final String P_CONTENT_LENGTH = "Content-Length";
protected static final String P_LATENCY = "Latency";
protected static final String P_REFERER = "Referer";
protected static final String P_USER_AGENT = "User-Agent";
@@ -94,6 +95,7 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
set(event, P_PROTOCOL, req.getProtocol());
set(event, P_STATUS, rsp.getStatus());
set(event, P_CONTENT_LENGTH, rsp.getContentCount());
set(event, P_LATENCY, System.currentTimeMillis() - req.getTimeStamp());
set(event, P_REFERER, req.getHeader("Referer"));
set(event, P_USER_AGENT, req.getHeader("User-Agent"));

View File

@@ -66,6 +66,9 @@ public final class HttpLogLayout extends Layout {
buf.append(' ');
opt(buf, event, HttpLog.P_CONTENT_LENGTH);
buf.append(' ');
opt(buf, event, HttpLog.P_LATENCY);
buf.append(' ');
dq_opt(buf, event, HttpLog.P_REFERER);