关于nginx日志中的time_local
问题描述
想基于nginx日志统计某一接口如秒杀的最大并发数
nginx日志格式是这样配置的
log_format: $remote_addr [$time_local] "$request" $status $upstream_response_time $body_bytes_sent
Nginx官方文档是这样定义time_local
的
$time_local
local time in the Common Log Format
现在不确定这是请求过来的时间 还是请求处理完毕后记录此条日志的时间 只有是前者才能基于该时间统计最大并发数吧
摘自: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.
这篇关于关于nginx日志中的time_local的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!