spring boot内嵌tomcat访问日志的常用配置

注:该文章是问了方便自己查询,转载的其他人的,转载连接:https://maoyunfei.github.io/spring/76c7f26f/

tomcat log的配置

server:
  tomcat:
    accesslog:
      enabled: true		#是否开启日志
      directory: /tmp/accesslogs/mobile-site   #日志存储目录
      pattern: '%t %a %A %m %U%q %s %D %I %B'  #日志格式
      prefix: access		#日志文件前缀
      rename-on-rotate: true	 #是否启用日志轮转

pattern配置的说明

  • %a - Remote IP address,远程ip地址,注意不一定是原始ip地址,中间可能经过nginx等的转发
  • %A - Local IP address,本地ip
  • %b - Bytes sent, excluding HTTP headers, or ‘-’ if no bytes were sent
  • %B - Bytes sent, excluding HTTP headers
  • %h - Remote host name (or IP address if enableLookups for the connector is false),远程主机名称(如果resolveHosts为false则展示IP)
  • %H - Request protocol,请求协议
  • %l - Remote logical username from identd (always returns ‘-’)
  • %m - Request method,请求方法(GET,POST)
  • %p - Local port,接受请求的本地端口
  • %q - Query string (prepended with a ‘?’ if it exists, otherwise an empty string
  • %r - First line of the request,HTTP请求的第一行(包括请求方法,请求的URI)
  • %s - HTTP status code of the response,HTTP的响应代码,如:200,404
  • %S - User session ID
  • %t - Date and time, in Common Log Format format,日期和时间,Common Log Format格式
  • %u - Remote user that was authenticated
  • %U - Requested URL path
  • %v - Local server name
  • %D - Time taken to process the request, in millis,处理请求的时间,单位毫秒
  • %T - Time taken to process the request, in seconds,处理请求的时间,单位秒
  • %I - current Request thread name (can compare later with stacktraces),当前请求的线程名,可以和打印的log对比查找问题
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值