10

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.

1 Answer 1

18

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.

5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .