zoukankan      html  css  js  c++  java
  • 接口耗时打印并统计

    1.可以利用Tomcat的access-log日志,让其打印出http请求的每次耗时。可以在

    config/server.xml里Host标签下配置tomcat访问日志格式

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                   prefix="localhost_access_log." suffix=".txt"
                   pattern="%h %l %u %t &quot;%r&quot; [%{postdata}r] %s %{Referer}i %{User-Agent}i %T %b" />

    2.但这样只会打印每次的http请求耗时,并没有统计功能,如记录每个接口的平均耗时,记录超时接口,如超过1000ms的接口。

    不直观的acces-log日志:10.118.129.28 4.1.5.24 - - 0.361 [28/Dec/2017:09:24:48 +0800] 361 GET /m/offerItem/queryOfferItemList?reqSystem=ICORE-PAP&idProfitOfferItem=&type=&subType=&name=&status=&pageNum=4&startTime=&endTime=&pageSize=10 HTTP/1.1 200 5468

    10.118.129.28 4.1.5.24 - - 0.165 [28/Dec/2017:09:24:59 +0800] 165 GET /docc/giftConfig.jsp?tabId=f432ef47-e139-ec58-d81e-15aa7b348e2a&sysdate=1514424299261_0.5705513903091453 HTTP/1.1 200 16080
    10.118.129.28 4.1.5.24 - - 0.005 [28/Dec/2017:09:24:59 +0800] 5 GET /js/giftConfig.js HTTP/1.1 304 -
    10.118.129.28 4.1.5.24 - - 0.204 [28/Dec/2017:09:25:01 +0800] 204 GET /m/offer/getOfferList?reqSystem=ICORE-PAP&idProfitOffer=&name=&type=&subType=&status=&pageNum=1&pageSize=10 HTTP/1.1 200 3774


    3.写个shell/python脚本分析这个日志,做好统计功能,频次每次+1,每次重新计算平均耗时
  • 相关阅读:
    适用于小白的 python 快速入门教程
    Centos7.x & RedHat7.x系统忘记 root 密码解决办法
    让我来教你如何免费使用RHEL小红帽系统
    10#Windows注册表的那些事儿
    9#搭建网站
    8#继承和多态
    7#Java基本语句语法
    6#day2总结
    5#关于数据数值的转换
    .NET Core开发日志——配置
  • 原文地址:https://www.cnblogs.com/panxuejun/p/8134935.html
Copyright © 2011-2022 走看看