您的位置:首页 > 运维架构 > 网站架构

IIS 网站日志时间延迟及解决方法

2011-04-08 17:17 507 查看
刚上线的IIS观察了下日志文件

结果发现日志文件明显延迟了八个小时。

经过一番查询,在MS官方找到了答案。

IIS Log File Entries Have the Incorrect Date and Time Stamp

SYMPTOMS

The date and the time stamp on entries in the IIS log files appear to be incorrect by several hours when you compare the date and the time stamp to the local time on the server.

CAUSE

The selected log file format is the W3C Extended Log File Format. The extended log file format is defined in the W3C Working Draft WD- logfile-960323 specification by Phillip M. Hallam-Baker and Brian Behlendorf. This document defines the Date and Time files to always be in GMT. This behavior is by design.

Resolution 1

Change the active logging format to the Microsoft IIS Log File Format. This format logs in the server's Local Time.

Resolution 2

Use the Convlog.exe utility, which is located in the Winnt\System32 folder, to convert the log to the NCSA Log File Format and server's local time. At a command prompt, type the following:

convlog -ie LogFileName -t ncsa:+/-GMTOffset

where LogFileName is the name of the file to convert and GMTOffset is the number of hours to correct.

For example, to convert a file named "Logfile.log," and correct for Eastern Standard Time, you would use the following command:

convlog -ie Logfile.log -t ncsa:-0500

You can find complete instructions on how to use the Convlog utility in the IIS online documentation.

链接:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q271196

上面讲的大概意思是,由于IIS默认的日志格式为W3C标准日志文件,而W3C是按照GMT时间进行记录的。中国刚好是GMT+8,所以,记录的时间数值上差了8小时,实际上是实时的。

解决方法1:

使用 Microsoft IIS日志文件格式 进行记录

“打开“Internet 信息服务(IIS)管理器”,点击“Internet信息服务”、“本地计算机”、“网站”,在需要的网站上(如果要设置所有的网站,则直接在“网站”上)右击“属性”,打开网站属性。

在“网站”标签下找到“活动日志格式”,点击其后的“属性”,打开IIS日志属性

在IIS日志属性“常规”标签下,找到“文件命名和创建使用当地时间”,在其前打勾。

点击两次“确定”退出“Internet 信息服务(IIS)管理器”。 ”

解决方法2:

使用日志转换命令convlog

用法: convlog [options] LogFile

选项:

-i<i|n|e> = 输入日志文件类型

i - MS Internet 标准日志文件格式

n - NCSA 公用日志文件格式

e - W3C 扩展日志文件格式

-t <ncsa[:GMTOffset] | none> 默认值是 ncsa

-o <output directory> 默认值 = 当前目录

-x 将非 www 数据项保存到 .dmp 日志文件

-d = 将 IP 地址转换成 DNS

-l<0|1|2> = MS Internet 标准日期格式

0 - 月/日/年(默认值,如美国)

1 - 年/月/日(如中国)

2 - 日.月.年(如德国)

-c = 即使发现格式不正确,也继续执行

如:

convlog -ii in*.log -d -t ncsa:+0800

convlog -in ncsa*.log -d

convlog -ii jra*.log -t none
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 IIS 休闲