spring-boot - Spring Boot中的Jetty自定义格式日志模式
问题描述
我们已将 Spring Boot 应用程序升级到 2.5,因此码头升级到 9.X
通过此更新,server.jetty.accesslog.time-zone 不再是 application.property 中的有效条目。我们需要 IST 中的时区,现在它是 GMT(默认)。知道如何将其设置为 IST。
升级前 access.log
0:0:0:0:0:0:0:1 - - [20/Jul/2021:14:31:10 +0530] "POST /hotels/generate/partial/v1/refresh-hotel-tagging HTTP/1.1" 200 7 211960
我尝试使用server.jetty.accesslog.custom-format= %{dd/MMM/yyyy:HH:mm:ss SSS}t
which 给出:[15/Sep/2021:13:11:47 942]
我们需要像以前一样的日志格式。
解决方案
这在 javadoc 中得到了回答CustomRequestLog
%{format|timeZone|locale}t
The time that the request was received. Optional parameter in one of the following formats {format}, {format|timeZone} or {format|timeZone|locale}.
Format Parameter: (default format [18/Sep/2011:19:18:28 -0400] where the last number indicates the timezone offset from GMT.)
Must be in a format supported by DateCache
TimeZone Parameter:
Default timeZone GMT
Must be in a format supported by TimeZone.getTimeZone(String)
Locale Parameter:
Default locale Locale.getDefault()
Must be in a format supported by Locale.forLanguageTag(String)
因此,请以您的格式使用您想要的时区...
%{dd/MMM/yyyy:HH:mm:ss SSS|IST}t
您还可以选择指定区域设置(这对指定很有用。例如,如果您决定使用长名称来表示月份)
使用 IST + 日语语言环境
%{dd/MMM/yyyy:HH:mm:ss SSS|IST|ja}t
推荐阅读
- python - 在数据框中复制单行
- c# - 即使我正在等待也无法调试异步方法
- javascript - 通过提供 start 和 endtime 参数从末尾到第一项查询分页 API 端点
- node.js - Jest 自定义测试环境不能使用绝对路径
- drivine - 如何将connectionPooling和超时相关的属性传递给Drivine connectionProvider
- excel - VBA:转换数字格式/刷新单元格
- reactjs - 带有 React UI(脚手架)的 Laravel 8 的 Docker 文件
- c++ - 在点数组中找到最小值的算法
- assembly - ARM 程序集无法从地址加载
- html - html-验证时输入背景颜色更新