I'm reading some nginx logs for some rather long-lasting requests (up to 10 seconds). In the log format, we're using the $time_local
variable to record the time. But does this mean the time when the request started or when it finished? For a long-running request, these are quite distinct times, and I can't find anything in the ngx_http_log_module documentation to explain this.
Add a comment
|
1 Answer
The $time_local
variable contains the time when the log entry is written.
when the HTTP request header is read, nginx does a lookup of the associated virtual server configuration. If the virtual server is found, the request goes through six phases:
- server rewrite phase
- location phase
- location rewrite phase (which can bring the request back to the previous phase)
- access control phase
- try_files phase
- log phase
Since the log phase is the last one, $time_local
variable is much more colse to the end of the request than it's start.
-
thanks.. can you show me where I could have found this in the documentation? Oct 16, 2012 at 11:34
-
2nginx.com/docs.html The information is on the link "The Architecture of Open Source Applications Volume II" which is a good reference book. Oct 16, 2012 at 13:31
-
Looks like they've changed the URL. It's now at nginx.org/en/docs with the reference book at aosabook.org/en/nginx.html.– trssApr 7, 2018 at 10:50
-
-
NB this differs from Apache, which uses the start time in its default log httpd.apache.org/docs/2.2/mod/mod_log_config.html– WillemDec 19, 2022 at 14:16