Apache and Tomcat both make it easy to log response times out to the server access log (with the %D pattern), but I\'ve been unable to find any equivalent support in Jetty,
A good detailed explanation on how to enable response time logging through configuration is here: Monitoring latency in Jetty request log
Summary:
Open [JETTY HOME]/etc/jetty.xml.
Locate <Ref id=”RequestLog”> section.
Add Set name=”logLatency”>true to setter list.
Save it and restart Jetty.
Call setLogLatency(true)
on NCSARequestLog
Using logback access 1.1.0 or later, you can use the %elapsedTime
conversion word to get the response time in ms. From https://logback.qos.ch/manual/layouts.html :
D / elapsedTime The time taken to serve the request, in milliseconds. T / elapsedSeconds The time taken to serve the request, in seconds.
For example, using:
<pattern>%h %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" %elapsedTime{}ms</pattern>
Will output:
0:0:0:0:0:0:0:1 - - [03/Jun/2018:08:07:12 +1200] "GET /actuator/health HTTP/1.1" 200 15 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" 3ms