Board logo

标题: [求助] 如何更改APACHE日志的格式? [打印本页]

作者: tiantangld    时间: 2012-6-9 12:13     标题: 如何更改APACHE日志的格式?

近日想更改APACHE日志的格式,使其能记录访客的User-Agent信息到日志里,但是百度了很多资料,还是没能学会

现在的日志记录下来是这样:
  1. 10.1.1.95 - e800 [18/Mar/2005:12:21:42 +0800] "GET /stats/awstats.pl?config=e800 HTTP/1.1" 200 899
复制代码


我想改成这样:
  1. 10.1.1.95 - e800 [18/Mar/2005:12:21:42 +0800] "GET /stats/awstats.pl?config=e800 HTTP/1.1" 200 899 "http://10.1.1.1/pv/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Maxthon)"
复制代码


哪位大哥知道怎么修改呢?







以下为小弟http.conf的部分信息,不知道是不是改这里?
  1. <IfModule log_config_module>
  2.     #
  3.     # The following directives define some format nicknames for use with
  4.     # a CustomLog directive (see below).
  5.     #
  6.     LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  7.     LogFormat "%h %l %u %t \"%r\" %>s %b" common
  8.     <IfModule logio_module>
  9.       # You need to enable mod_logio.c to use %I and %O
  10.       LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  11.     </IfModule>
  12.     #
  13.     # The location and format of the access logfile (Common Logfile Format).
  14.     # If you do not define any access logfiles within a <VirtualHost>
  15.     # container, they will be logged here.  Contrariwise, if you *do*
  16.     # define per-<VirtualHost> access logfiles, transactions will be
  17.     # logged therein and *not* in this file.
  18.     #
  19.     CustomLog "logs/access_log" common
  20.     #
  21.     # If you prefer a logfile with access, agent, and referer information
  22.     # (Combined Logfile Format) you can use the following directive.
  23.     #
  24.     #CustomLog "logs/access_log" combined
  25. </IfModule>
复制代码

作者: admin    时间: 2012-6-9 15:37

CustomLog "logs/access_log" common
改为
CustomLog "logs/access_log" combined
就可以
作者: tiantangld    时间: 2012-6-9 18:32

回复 2# admin


    非常感谢
作者: tiantangld    时间: 2012-6-9 23:29

回复 2# admin


    老大,我试着更改重启了还是不行哦,是不是我改错哪里了,麻烦老大帮忙在看一下

我更改后,日志还是这样子的
  1. 95.211.139.1 - - [09/Jun/2012:23:16:04 +0800] "GET /store/shoplist-14.html HTTP/1.0" 200 -
复制代码



最后附httpd.conf

  1. <IfModule log_config_module>
  2.     #
  3.     # The following directives define some format nicknames for use with
  4.     # a CustomLog directive (see below).
  5.     #
  6.     LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  7.     LogFormat "%h %l %u %t \"%r\" %>s %b" common
  8.     <IfModule logio_module>
  9.       # You need to enable mod_logio.c to use %I and %O
  10.       LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  11.     </IfModule>
  12.     #
  13.     # The location and format of the access logfile (Common Logfile Format).
  14.     # If you do not define any access logfiles within a <VirtualHost>
  15.     # container, they will be logged here.  Contrariwise, if you *do*
  16.     # define per-<VirtualHost> access logfiles, transactions will be
  17.     # logged therein and *not* in this file.
  18.     #
  19.     CustomLog "logs/access_log" combined
  20.     #
  21.     # If you prefer a logfile with access, agent, and referer information
  22.     # (Combined Logfile Format) you can use the following directive.
  23.     #
  24.     #CustomLog "logs/access_log" combined
  25. </IfModule>
  26. <IfModule alias_module>
复制代码

作者: admin    时间: 2012-6-10 00:36

这样是对的
作者: tiantangld    时间: 2012-6-10 01:38

回复 5# admin


    终于找到问题所在了,单单修改这里还不行,还要去修改虚拟主机配置文件
作者: admin    时间: 2012-6-10 10:36

这个是默认的记录文件,也是所有的
虚拟主机里的是针对站点的




欢迎光临 WDlinux官方论坛 (http://wdlinux.cn/bbs/) Powered by Discuz! 7.2