SpringBoot如何配置tomcat access_log日志

在配置文件application.yml里面来配置tomcat accesslog日志:

server:  port: 80  tomcat:    accesslog:      enabled: true      directory: D:DocumentsD_代码相关J_javasprintboot_study      prefix: tomcat_access_log      suffix: .log      file-date-format: -yyyy-MM-dd      pattern: '%{X-Real-IP}i - %{Host}i %t "%r" %{Content-Length}i %s %b %D "%{Referer}i" "%{User-Agent}i" %a "%I" "-"'      rotate: true

登录后复制

日志记录格式(pattern),形式参照 :

nginx 日志 log_format:

log_format main '$http_x_real_ip - $http_host [$time_local] "$request" $request_length '                             '$status $body_bytes_sent $request_time "$http_referer" '                             '"$http_user_agent" $remote_addr "-" "-" ';

登录后复制

tomcat access log pattern:

pattern: '%{X-Real-IP}i - %{Host}i %t "%r" %{Content-Length}i'              '%s %b %D "%{Referer}i"'             '"%{User-Agent}i" %a "%I" "-"'

登录后复制

%{X-Real-IP}i: http X-Real_IP%{Host}i: http Host%t: Date and time, in Common Log Format%r: First line of the request (method and request URI)%{Content-Length}i: request length%s: HTTP status code of the response%b: Bytes sent, excluding HTTP headers, or ‘-’ if zero%D: Time taken to process the request, in millis%{Referer}i: http Referer%{User-Agent}i: http User-Agent%a: Remote IP address%I: Current request thread name (can compare later with stacktraces)

登录后复制

以上就是SpringBoot如何配置tomcat access_log日志的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2603571.html

(0)
上一篇 2025年3月6日 19:42:10
下一篇 2025年3月1日 14:11:50

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论