How to enable response time logging in Jetty 7

前端 未结 3 1321
醉话见心
醉话见心 2021-01-05 04:19

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,

3条回答
  •  别那么骄傲
    2021-01-05 04:49

    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:

    %h %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" %elapsedTime{}ms
    

    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
    

提交回复
热议问题