I'd like to have the timestamps in my Nginx error logs the same as in my access logs.
The error times have the format
Y/m/d H:i:s whereas the access logs allow me either:
d/M/Y:H:i:s O($time_local) or
Is there any way I can set my access logs to use the error log format or vice versa?
I'm running Nginx 1.10.1 on CentOS 7.
As my question has been downvoted, I shall try to be crystal clear -
access_log directive allows me to define the timestamp used in access logs, although it seems I only have two choices of format. for example:
log_format foo '[$time_local] "$request" $status ..'; log_format bar '[$time_iso8601] "$request" $status ..';
I can then apply these formats to access logs like this:
access_log foo.log foo; access_log bar.log bar;
Tailing all the logs shows the different time formats, e.g.
==> foo.log <== [29/Sep/2016:10:20:48 +0100] "GET /fail HTTP/1.1" 404 .. ==> bar.log <== [2016-09-29T10:20:48+01:00] "GET /fail HTTP/1.1" 404 .. ==> error_log <== 2016/09/29 10:37:52 [error] ..... No such file or directory
$time_iso8601 match the format used in the standard Nginx error log. I have tried to solve this in two ways:
- Configure error logging to use either
~ I have failed to find any directive that can do this.
- Configure the access log time format to match the error log time format.
~ I have failed to find any variables that can do this.
I am not married to any particular time format, but I would like them to match in my error logs as it saves me time when cross referencing access and error log entries.
If anyone knows how to achieve either 1. or 2. above, I'd love to know. Thanks.