W3C 日志时间与系统时间相差8小时的问题,晚八小时
u_ex200610.log
#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2020-06-10 09:56:48
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2020-06-10 09:56:48 192.168.0.2 GET /logs - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 2 45
2020-06-10 09:56:48 192.168.0.2 GET /logs - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 2 36
2020-06-10 09:56:50 192.168.0.2 GET /logs - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 2 47
#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2020-06-10 09:57:56
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2020-06-10 09:57:56 192.168.0.2 GET /logs - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 2 57
2020-06-10 09:57:56 192.168.0.2 GET /logs - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 2 38
2020-06-10 09:58:05 192.168.0.2 GET /logs - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 2 39
2020-06-10 09:58:05 192.168.0.2 GET /logs - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 2 52
2020-06-10 09:58:09 192.168.0.2 GET /logsfdfdfd - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 2 31
#Date: 2020-06-10 10:22:46
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken
2020-06-10 10:22:46 192.168.0.2 GET /1.jpg - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 200 0 0 10889501 705 114056
2020-06-10 10:22:46 192.168.0.2 GET /favicon.ico - 80 - 110.90.102.248 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.14;+rv:77.0)+Gecko/20100101+Firefox/77.0 404 0 64 0 621 37
IIS
u_in200610.log
110.90.102.248, -, 6/10/2020, 17:39:23, W3SVC3, INSTANCE-2HS5MS, 192.168.0.2, 305, 733, 1323, 404, 2, GET, /cloiudduo, -,
110.90.102.248, -, 6/10/2020, 17:39:35, W3SVC3, INSTANCE-2HS5MS, 192.168.0.2, 40, 783, 210, 304, 0, GET, /, -,
110.90.102.248, -, 6/10/2020, 17:39:37, W3SVC3, INSTANCE-2HS5MS, 192.168.0.2, 32, 619, 0, 404, 64, GET, /favicon.ico, -,
196.52.43.105, -, 6/10/2020, 17:47:03, W3SVC3, INSTANCE-2HS5MS, 192.168.0.2, 590, 148, 1276, 200, 0, GET, /, -,
NCSA
u_nc200610.log
110.90.102.248 - - [10/Jun/2020:17:55:07 +0800] "GET /logs HTTP/1.1" 404 1323
110.90.102.248 - - [10/Jun/2020:17:55:07 +0800] "GET /favicon.ico HTTP/1.1" 404 0
110.90.102.248 - - [10/Jun/2020:17:55:09 +0800] "GET /logs HTTP/1.1" 404 1323
110.90.102.248 - - [10/Jun/2020:17:55:36 +0800] "GET /logs HTTP/1.1" 404 1323
110.90.102.248 - - [10/Jun/2020:17:55:37 +0800] "GET /logs HTTP/1.1" 404 1323
关于windows IIS日志时间与系统时间相差8小时的问题
切换日志格式立即生效,无需重启IIS或则IIS站点
很多做过网站的朋友在分析IIS日志的时候会发现IIS日志的时间与计算机的系统时间不符,比如在中国时区就会相差8小时。具体原因是什么呢?网 上搜索的结果十有八九让人做如下操作解决:
在IIS日志属性“常 规”标签下,找到“文件命名和创建使用当地时间”,在其前打勾。实际上,这种方法并不能解决时差问题。
真正的原因是因为IIS默认 采用W3C 扩展日志文件格式,而W3C 扩展日志文件定义日志采用GMT时间(即格林尼治标准时间),而中国在GMT +8时区,自然就相差八个小时了。要真正解决,有两个办法:
1:活动日志格式更改为 “Microsoft IIS 日志文件格式”。此时时间一致。但是。。IIS日志文件格式记录的日志文档 内容不如W3C扩展日志文件格式的文档丰富,比如cs(User-Agent)段的信息就不会有,如果你很重视这些,那不要用此方法了。
2: 使用转化工具转化,如Convlog.exe 实用程序, 位于 Winnt\System 32 文件夹,由微软提供。在命令提示符处, 键入: convlog - IE LogFileName - t ncsa +/- GMTOffset : 其中 LogFileName 是对转换文件和 GMTOffset 名称是的要更正小时数。 即本地时间与GMT时间差。 例如, 来转换文件命名为 " Logfile.log, " 和更正有关东部标准时间, 请使用以下命令: convlog - IE Logfile.log - t ncsa -0500:
附上命令详解:
用法: convlog [options] LogFile
选项:
-i*= 输入日志文件类型*
i - MS Internet 标准日志文件格式
n - NCSA 公用日志文件格式
e - W3C 扩展日志文件格式
-t 默认值是 ncsa
-o 默认值 = 当前目录
-x 将非 www 数据项保存到 .dmp 日志文件
-d = 将 IP 地址转换成 DNS
-l = 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
比如:
convlog -ii in*.log -d -t ncsa:+0800
命令将以in为前缀、.log为后缀的所有log文件转换成带有 DNS 名称的 NCSA 公用日志文件格式,纠正 8 个小时的 GMT 时差。
convlog -ie ex121231.log -l1 -t ncsa:-0800 -o \Logfiles\California\
命令将 Inetsv1.log 文件命令将ex121231.log文件从 W3C 日志文件格式转换成 NCSA 公用日志文件格式,纠正 8 个小时的 GMT 时差(即加利福尼亚州时间),将日期格式设置为年/月/日格式,并将其发送到当前驱动器上 Logfiles 目录 California 子目录中。
convlog -in ncsa*.log -d
命令将以ncsa为前缀、.log为后缀的所有文件以转换为 NCSA 公用日志文件格式。IP 地址由 DNS 名称替换,但文件格式不进行转换。
convlog -ii jra*.log -t none
由 DNS 转换过程所产生的文件名遵循如下约定:
转换为 NCSA 公用日志文件格式但未进行 DNS 转换的日志文件将保留原来的文件名,并使用 .ncsa 文件扩展名。
IP 地址转换为 DNS 名称的日志文件将保留原来的文件名,并使用 .ncsa.dns 文件扩展名。
例如,如果 inetsv1.log 是使用 IIS 日志文件格式的日志文件,在不进行 DNS 转换时,得到的输出日志文件是 Inetsv1.log.ncsa。但是,如果启用了 DNS 转换功能,则得到的输出日志文件是 Inetsv1.log.ncsa.dns。
ex121231.log.ncsa --> ex121231.log
rename *.ncsa *.
批量修改扩展名.log.ncsa为.log