Logging format

How can I change the time zone and format of $time_local in the log format?

Is there a way to get json logging without the paid version?

JSON logging is already free. Ref: Module ngx_http_log_module

Not sure about how to change the timezone or the format of $time_local, though.

Hi there,

The local time zone that nginx uses is based on the TZ environment variable that was in the environment when nginx was started; or is based on the server /etc/localtime file if there is no TZ.

So the common case is that it all Just Works by matching the server time zone; but if you want a time zone for nginx that is not the same as the time zone of the server, then you should change your nginx start-up script to set TZ. You might be able to use env ( Core functionality ) within the nginx conf file, if you can’t change the start-up script; but that seems not to be preferred.

The format of $time_local is not configurable.

You can configure json-format access logs by using log_format ( Module ngx_http_log_module ) with escape=json, with a reasonable-looking example external to nginx shown at Nginx JSON Logging Setup for ML Production Systems .

You cannot configure json-format error logs in stock nginx. According to Core functionality , that can be done as part of the commercial subscription.

Cheers,