如何在 Apache 2.0 中以毫秒精度对请求日志进行时间戳

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/335433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:59:22  来源:igfitidea点击:

How to timestamp request logs with millisecond accuracy in Apache 2.0

apachetiming

提问by Ben Williams

How do I configure Apache 2.0's log format so that it timestamps each request log with millisecond (or microsecond) accuracy? The docssay that timestamps are specified in strftime format and strftime doesn't seem to handle anyting smaller than seconds.

如何配置 Apache 2.0 的日志格式,以便它以毫秒(或微秒)精度为每个请求日志添加时间戳?该文件说,时间戳中的strftime格式和strftime规定似乎并没有处理点儿小于秒的。

采纳答案by Martin v. L?wis

I don't think it's possible (without rewriting APR, atleast). Apache uses apr_strftime. On Unix, this calls the C library's strftime, but doesn't even fill milliseconds into struct tm (not surprisingly, because this structure doesn't usually support milliseconds in the first place). The Windows versions isn't much different.

我认为这是不可能的(至少不重写 APR)。Apache 使用apr_strftime。在 Unix 上,这会调用 C 库的 strftime,但甚至不会将毫秒填充到 struct tm 中(这并不奇怪,因为该结构通常首先不支持毫秒)。Windows 版本没有太大不同。

回答by Kerem Can Karaka?

use %D option for microsecond accuracy

使用 %D 选项以获得微秒精度