日志解析器 2.2 跳过当今的 IIS 日志
我试图通过使用 Log Parser 2.2 解析 IIS 日志来计算网站上特定 URL 的点击次数。一切似乎都工作正常,除了它对时间戳的处理让我非常困惑。
IIS 日志具有以 UTC 时间表示的所有时间戳。因此,在我的应用程序中,我将服务器时间转换为 UTC,然后再将其插入查询。但是,当我尝试查询当天的数据时,尽管我看到了日志文件中的记录,但我得到的计数为零。我尝试运行以获取当天内所有内容的生成查询看起来像这样(查询于 2009 年 11 月 11 日运行,我使用的是亚利桑那州时间):
SELECT COUNT(*)
FROM \\Server\IIS Logs\LogFiles\W3SVC1\u_ex*.log
WHERE
cs-method = 'GET'
AND cs(Referer) NOT LIKE '%ntorus%'
AND c-ip NOT LIKE '192%'
AND c-ip NOT LIKE '127%'
AND (
cs-uri-stem = '/'
OR cs-uri-stem = '/myurl')
AND sc-status BETWEEN 200 AND 299
AND date BETWEEN
TIMESTAMP('2009-11-11 07:00', 'yyyy-MM-dd hh:mm')
AND TIMESTAMP('2009-11-12 07:00', 'yyyy-MM-dd hh:mm')
由于某种原因,当天的数据看起来是被跳过。当查询较早的日期时,我可以正常返回数据。为什么会发生这种情况?
I'm trying to count the number of hits for a particular URL on our web site by parsing our IIS logs using Log Parser 2.2. Everything seems to be working fine, except that its handling of timestamps is greatly confusing me.
The IIS logs have all of the timestamps expressed in UTC time. Therefore, in my application, I convert the server's time to UTC before plugging it into the query. However, when I try to query for the current day's data, I get back a zero count, despite me seeing the records in the log file. The generated query I try to run to get everything within the current day looks something like this (the query is run on 11/11/2009, and I'm using Arizona time):
SELECT COUNT(*)
FROM \\Server\IIS Logs\LogFiles\W3SVC1\u_ex*.log
WHERE
cs-method = 'GET'
AND cs(Referer) NOT LIKE '%ntorus%'
AND c-ip NOT LIKE '192%'
AND c-ip NOT LIKE '127%'
AND (
cs-uri-stem = '/'
OR cs-uri-stem = '/myurl')
AND sc-status BETWEEN 200 AND 299
AND date BETWEEN
TIMESTAMP('2009-11-11 07:00', 'yyyy-MM-dd hh:mm')
AND TIMESTAMP('2009-11-12 07:00', 'yyyy-MM-dd hh:mm')
It looks like for some reason the current day's data is getting skipped. When querying earlier dates, I get back data just fine. Why is this happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
雅各布,
谢谢你的帖子。我在比较 IIS 日志中的日期/时间时也遇到了问题。通过结合您的问题和解决方案,我能够在没有 TO_STRING 的情况下进行搜索。
完整来源:
Jacob,
Thanks for your post. I was also having trouble comparing date/times in IIS logs. By combining your question and solution I was able to search without the TO_STRING.
Full Source:
事实证明,日志解析器无法正确进行时间戳比较。但是,当我将时间戳转换为字符串时,字符串比较工作正常。修改后的查询如下所示:
It turns out that Log Parser doesn't do time stamp comparisons properly. However, when I converted the time stamps to strings, string comparison worked fine. Here's what the modified query looks like:
Log Parser 有一个功能可以为您将时间从 UTC 转换为本地时间:
Log Parser has a function to convert the time from UTC to local for you: