SpringBoot 记录 access.log 日志 如何将不同业务模块产生的日志 分多文件记录

Tomcat 中有个日志 loca_access.log 可以记录每个接口的请求耗时,用于做性能等分析比较有用,SpringBoot里,默认不记录这个日志,可以在 yml里做如下配置,开启这样的日志,

server:
  tomcat:
    #basedir: /var/tmp  
    background-processor-delay: 30
    redirect-context-root: true
    uri-encoding: UTF-8
    accesslog:
      enabled: true #为true时,上面的日期格式才有意义,否则就是写在一个文件里了
      buffered: true
      directory: ./logs  #记录在 jar 运行的同级目录中的 logs 目录下,可以与 logback 记录目录配置一致
      file-date-format: .yyyy-MM-dd
      #pattern: '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" %D ms'
      pattern: '%t %a %m %U %s %b %D ms'   #%D 请求耗时N毫秒
      prefix: access_log
      rename-on-rotate: false
      request-attributes-enabled: false
      rotate: true
      suffix: .log

结合 Python 脚本,分析接口请求次数、平均耗时等操作

如何将不同业务模块产生的日志 分多文件记录

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章