How to enable response time logging in Jetty 7

前端 未结 3 1320
醉话见心
醉话见心 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:30

    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.

    0 讨论(0)
  • 2021-01-05 04:45

    Call setLogLatency(true) on NCSARequestLog

    0 讨论(0)
  • 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:

    <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
    
    0 讨论(0)
提交回复
热议问题