This is follow up question for configure jetty logging. Is there any attribute that gives the time taken by the request?
123.4.5.6 - - [27/Aug/2004:10:16:17 +0000] "GET /jetty/tut/XmlConfiguration.html HTTP/1.1" 200 76793 "http://localhost:8080/jetty/tut/logging.html" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040614 Firefox/0.8"
The above params are already defined in the configure jetty logging. but I do not see any param that gives us the time taken by the request.
Note - it used to be called log latency in the jetty9 - jetty9 custom logging
You will need to change the format string of CustomRequestLog
to include the %T
percent code. This is documented in the javadoc for CustomRequestLog
. (see https://javadoc.io/doc/org.eclipse.jetty/jetty-server/latest/org.eclipse.jetty.server/org/eclipse/jetty/server/CustomRequestLog.html)
If you are not using CustomRequestLog
and extending RequestLog
yourself you can get the latency yourself by doing:
long latency = System.currentTimeMillis() - request.getTimeStamp();