How to Display $time_local in Nginx access.log in Japan Time

Asked 2 years ago, Updated 2 years ago, 50 views

The $time_local output in Nginx access.log appears to be UTC+0 by default.
I would like to change this to Japan time output.

The current $time_local output is [28/Feb/2016:01:46:24+0000].

I couldn't find a way to set it up when I looked at the net or Nginx pocket reference.
If you know how to set it to Japan time, please let me know.

The operating system is Amazon Linux.

nginx

2022-09-30 18:01

1 Answers

Is the OS time zone not Asia/Tokyo?
If the OS time zone is Asia/Tokyo, $time_local is +9 hours.
You can change the time zone to Asia/Tokyo or start nginx with the environment variable TZ='Asia/Tokyo'.
The configuration method depends on the Linux distribution, but if you are RHEL/CentOS-based, you can change the time zone by

#cp/usr/share/zoneinfo/Asia/Tokyo/etc/localtime

I think you can do it with


2022-09-30 18:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.