日期:2014-05-17  浏览次数:21129 次

配置apache产生日志,但不包括图片,但没有好用?为什么
配置apache产生日志,但不包括图片,但没有好用?为什么

<IfModule log_config_module>

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
#LogFormat "%h %l %u %t \"%r\" %>s %b" common

SetEnvIf Request_URI \.gif$ gif-image
SetEnvIf Request_URI \.GIF$ gif-image
SetEnvIf Request_URI \.jpg$ gif-image
SetEnvIf Request_URI \.JPG$ gif-image
SetEnvIf Request_URI \.png$ gif-image
SetEnvIf Request_URI \.swf$ gif-image
SetEnvIf Request_URI \.SWF$ gif-image
SetEnvIf Request_URI \.css$ gif-image
SetEnvIf Request_URI \.CSS$ gif-image
SetEnvIf Request_URI \.js$ gif-image
SetEnvIf Request_URI \.JS$ gif-image
SetEnvIf Request_URI \.ico$ gif-image

<IfModule logio_module>  
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "|/usr/local/sbin/cronolog /usr/local/apps/apache2/logs/irunnet-access_log.%Y%m%d" combined

</IfModule>


以上配置的目的是产生日志,但不包括图片。
但是我的Apache日志依然是这样,为什么啊?
192.168.0.8 - - [03/Feb/2008:14:45:25 +0800] "GET /CultureDemo/images/bt_03_r.gif HTTP/1.1" 304 - "http://www.abc.com/CultureDemo/table2_1.htm" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler )"
192.168.0.8 - - [03/Feb/2008:14:45:25 +0800] "GET /CultureDemo/images/zp.jpg HTTP/1.1" 304 - "http://www.abc.com/CultureDemo/table2_1.htm" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler )"
192.168.0.8 - - [03/Feb/2008:14:45:25 +0800] "GET /CultureDemo/images/bt_04_b.gif HTTP/1.1" 304 - "http://www.abc.com/CultureDemo/table2_1.htm" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler )"
192.168.0.8 - - [03/Feb/2008:14:45:25 +0800] "GET /CultureDemo/images/bt_03_b.gif HTTP/1.1" 304 - "http://www.abc.com/CultureDemo/table2_1.htm" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler )"
192.168.0.8 - - [03/Feb/2008:14:45:26 +0800] "GET /CultureDemo/table_zc.htm HTTP/1.1" 304 - "http://www.abc.com/CultureDemo/left.htm" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler )"



------解决方案--------------------
gif-image 是你前面定义的呀
SetEnvIf Request_URI \.ico$ gif-image 
表示是。ico的请求就 这个gif-image定义了

然后好面进行了判断env=!gif-image 表示 gif-image 没有值或者没有定义就记录日志