SpringBoot-集成WEB容器AccessLog配置

SpringBoot项目集成WEB容器tomcat、undertow,access log配置,注意两者的微小差别,tomcat的日志目录关键字是basedir,undertow是directory。tomcat的扩展打印http头日志格式是%{xxx}i,undertow的扩展打印http头日志格式是%{i,xxx}

  1. 集成tomcat
1
2
3
server.tomcat.basedir=${log.path}
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms)

其中pattern 常用模式:common、combined

  • common - %h %l %u %t "%r" %s %b
  • combined - %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"

自定义pattern:

  1. 集成undertow
1
2
3
server.undertow.accesslog.directory=${log.path}
server.undertow.accesslog.enabled=true
server.undertow.accesslog.pattern=%t %a "%r" %s (%D ms)

其中pattern 常用模式:common、combined

  • common - %h %l %u %t "%r" %s %b
  • combined - %h %l %u %t "%r" %s %b "%{i,Referer}" "%{i,User-Agent}"

自定义pattern:

-------------本文结束感谢您的阅读-------------
Good for you!