Opened 2 years ago

Closed 2 years ago

#2344 closed enhancement (invalid)

Please allow to change the timezone for logs in the config file

Reported by: yurivict@… Owned by:
Priority: minor Milestone:
Component: documentation Version: 1.19.x
Keywords: Cc:
uname -a: FreeBSD mail.mojave-computing.com 13.0-RELEASE-p8 FreeBSD 13.0-RELEASE-p8 #0: Tue Mar 15 09:36:28 UTC 2022 root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
nginx -V: nginx version: nginx/1.20.2
built with OpenSSL 1.1.1k-freebsd 24 Aug 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --user=www --group=www --with-compat --modules-path=/usr/local/libexec/nginx --with-file-aio --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx/access.log --with-http_v2_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-pcre --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --without-mail_imap_module --without-mail_pop3_module --without-mail_smtp_module --with-mail_ssl_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-mail=dynamic --with-stream=dynamic

Description

Fixed timezone (+0000) in the log file isn't convenient - I prefer to see my own timezone for readability.

The "TZ" environment variable changes the timezone, but this variable has to be set in the RC file which makes it error-prone: when the nginx package is updated this setting needs to be re-set again.

I suggest to add the timezone setting to the nginx's config file.

Version 1.20.2
FreeBSD 13

Change History (1)

comment:1 by Maxim Dounin, 2 years ago

Resolution: invalid
Status: newclosed

nginx uses the timezone as configured in the system, using normal timezone configuration. That is, timezone from /etc/localtime by default, or the one set via TZ environment variable.

In most cases if you want nginx to use some timezone for logging, the most simple and most convenient way to do this is to set system default timezone via /etc/localtime.

If for some reason you want to set a specific timezone for nginx only, different from the one used by the rest of the system, the only consistent way to do this via the TZ environment variable before starting nginx. This ensures that proper timezone is used in all cases, including configuration parsing errors. It's up to your OS port/package startup scripts to provide a way to do this.

In some cases using the env TZ=<timezone>; configuration directive might be an acceptable solution. This will ensure that all nginx worker processes will use the specified timezone.

Hope this helps.

Note: See TracTickets for help on using tickets.