SpringBoot内嵌tomcat日志配置

SpringBoot的应用程序日志配置已经用了一段时间了,在resources下配置logback.xml文件即可。

今天要讲的是tomcat的日志如何配置。

如果SpringBoot是运行在tomcat容器中的,那么tomcat会默认生成localhost_access_log日志,如果是在SpringBoot的内嵌tomcat中,则只需要配置server.tomcat.accesslog.*

server:
  port: 8082
  tomcat:
    accesslog:
      buffered: true
      directory: E:/logs
      enabled: true
      file-date-format: .yyyy-MM-dd
      pattern: common
      prefix: access_log
      rename-on-rotate: false
      request-attributes-enabled: false
      rotate: true
      suffix: .log

详情参照官方文档:Configure Access Logging

运行后的结果是:

192.168.0.114 - - [13/Jun/2018:18:56:49 +0800] "OPTIONS /manage/login HTTP/1.1" 200 -
192.168.0.114 - - [13/Jun/2018:18:56:49 +0800] "POST /manage/login HTTP/1.1" 200 65
192.168.0.114 - - [13/Jun/2018:18:56:49 +0800] "OPTIONS /manage/device/getPage HTTP/1.1" 200 -
192.168.0.114 - - [13/Jun/2018:18:56:49 +0800] "POST /manage/device/getPage HTTP/1.1" 200 1379
192.168.0.114 - - [13/Jun/2018:18:56:52 +0800] "OPTIONS /manage/version/getPage HTTP/1.1" 200 -
192.168.0.114 - - [13/Jun/2018:18:56:52 +0800] "POST /manage/version/getPage HTTP/1.1" 200 3613
192.168.0.114 - - [13/Jun/2018:19:10:04 +0800] "OPTIONS /manage/config/getPage HTTP/1.1" 200 -
192.168.0.114 - - [13/Jun/2018:19:10:05 +0800] "POST /manage/config/getPage HTTP/1.1" 200 559
192.168.0.114 - - [13/Jun/2018:19:10:10 +0800] "OPTIONS /manage/config/add HTTP/1.1" 200 -
192.168.0.114 - - [13/Jun/2018:19:10:10 +0800] "POST /manage/config/add HTTP/1.1" 200 65
192.168.0.114 - - [13/Jun/2018:19:10:10 +0800] "POST /manage/config/getPage HTTP/1.1" 200 657
192.168.0.114 - - [13/Jun/2018:19:10:42 +0800] "OPTIONS /manage/device/getPage HTTP/1.1" 200 -
192.168.0.114 - - [13/Jun/2018:19:10:42 +0800] "POST /manage/device/getPage HTTP/1.1" 200 1379
192.168.0.114 - - [13/Jun/2018:19:10:45 +0800] "OPTIONS /manage/device/deleteByIds HTTP/1.1" 200 -
192.168.0.114 - - [13/Jun/2018:19:10:45 +0800] "POST /manage/device/deleteByIds HTTP/1.1" 200 65
192.168.0.114 - - [13/Jun/2018:19:10:45 +0800] "POST /manage/device/getPage HTTP/1.1" 200 1253
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值