search

Home  >  Q&A  >  body text

About time_local in nginx log

Want to count a certain interface such as flash sales based on nginx logsMaximum number of concurrencies The nginx log format is configured like this

log_format: $remote_addr [$time_local] "$request" $status $upstream_response_time $body_bytes_sent

Nginx official documentation defines time_local like this

$time_local

local time in the Common Log Format

Now I am not sure whether this is the time when the request comes in or the time when this log is recorded after the request is processed. Only the former can count the maximum number of concurrency based on this time

高洛峰高洛峰2750 days ago915

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-16 17:14:27

    摘自:http://serverfault.com/questi...

    The $local_time 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, $local_time variable is much more colse to the end of the request than it's start.

    reply
    0
  • Cancelreply