Apache 日志行出现乱序 - 为什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1027310/
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 17:46:58  来源:igfitidea点击:

Apache log lines appearing out of sequence - why?

apache

提问by PaulJWilliams

I've got an apache web server, and when a certain user accesses a certain page I get a log line who's timestamp is out of sync.

我有一个 apache 网络服务器,当某个用户访问某个页面时,我得到一个时间戳不同步的日志行。

Sample output:

示例输出:

IP1 - - [22/Jun/2009:12:20:40 +0000] "GET URL1" 200 3490 "REFERRING_URL1" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"

IP2 - - [22/Jun/2009:12:11:47 +0000] "GET URL2" 200 17453 "-" "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.0.11) Gecko/2009060214 Firefox/3.0.11"

IP3 - - [22/Jun/2009:12:20:41 +0000] "GET URL3" 200 889 "REFERRING_URL2" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB6; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; 3P_USEC 1.0.11.2; .NET CLR 3.5.30729; .NET CLR 3.0.30618)"

(I've anonymised requesting IPs - IP1, IP2 and IP3, requested URLs - URL1, URL2 and URL3, and the two referrrer URLs)

(我已匿名请求 IP - IP1、IP2 和 IP3,请求的 URL - URL1、URL2 和 URL3,以及两个引用 URL)

As can be seen the three lines (which appeared in the log in this order), are out of sync. This only happens when IP2 requests URL2 - all other logs seem normal.

可以看出,这三行(按此顺序出现在日志中)是不同步的。这仅在 IP2 请求 URL2 时发生 - 所有其他日志似乎正常。

Any ideas?

有任何想法吗?

回答by David Rabinowitz

The logs are written when the request is completed, so early long requests may be written after late short ones. Add %Dto your LogFormat definition to see the time taken to serve the request, in microseconds.

日志是在请求完成时写入的,因此早期的长请求可能会在后期的短请求之后写入。添加%D到您的 LogFormat 定义以查看为请求提供服务所花费的时间,以微秒为单位。

See more here

在这里查看更多

回答by Allain Lalonde

Maybe you're doing some kind of COMET requests?

也许您正在执行某种 COMET 请求?

My first thought is that the log only records the time at which the request finished? So maybe IP1's request took a while to complete but arrived before IP2's. Only requests I know that behave that way are AJAXey Comet requests.

我的第一个想法是日志只记录请求完成的时间?所以也许 IP1 的请求需要一段时间才能完成,但在 IP2 之前到达。我知道只有这样的请求才是 AJAXey Comet 请求。

Probably not the correct answer, by maybe a clue.

可能不是正确的答案,也许是一个线索。

Edit: http://www.linuxquestions.org/questions/linux-networking-3/apache-log-entries-order-516354/confirms that the time in the log includes the time required to transfer the content to the browser.

编辑http: //www.linuxquestions.org/questions/linux-networking-3/apache-log-entries-order-516354/确认日志中的时间包括将内容传输到浏览器所需的时间。