关于nginx日志中的time_local
高洛峰
高洛峰 2017-05-16 17:12:27
[Linux讨论组]

想基于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

现在不确定这是请求过来的时间 还是请求处理完毕后记录此条日志的时间 只有是前者才能基于该时间统计最大并发数吧

高洛峰
高洛峰

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

全部回复(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.

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号