About time_local in nginx log
高洛峰
高洛峰 2017-05-16 17:12:27
0
1
924

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

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
世界只因有你

摘自: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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template