We have upgraded spring boot application to 2.5 and as a result jetty is upgraded to 9.X
With this update server.jetty.accesslog.time-zone is no longer a valid entry in application.property. We need timezone in IST, right now it is coming in GMT (default). Any idea how to set it to IST.
Before upgrade 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
I tried with server.jetty.accesslog.custom-format= %{dd/MMM/yyyy:HH:mm:ss SSS}t
which gives : [15/Sep/2021:13:11:47 942]
We need the log format as before.
CodePudding user response:
This is answered in the javadoc on 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)
So use the timezone you want in your format ...
%{dd/MMM/yyyy:HH:mm:ss SSS|IST}t
You can also optionally specify the Locale (which is useful to specify. example if you decide to use long names for months)
Using IST Japanese locale
%{dd/MMM/yyyy:HH:mm:ss SSS|IST|ja}t