Apache日志中有许多不需要记录的,比如图片图像什么的。

这就需要我们去设置虚拟主机文件,把图片等一些不需要记录的去做一个标记,然后根据这个标记去做限制。

 

具体操作:

[root@No logs]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

 

SetEnvIf Request_URI ".*\.gif$" p_w_picpath-request
SetEnvIf Request_URI ".*\.jpg$" p_w_picpath-request
SetEnvIf Request_URI ".*\.png$" p_w_picpath-request
SetEnvIf Request_URI ".*\.bmp$" p_w_picpath-request
SetEnvIf Request_URI ".*\.swf$" p_w_picpath-request
SetEnvIf Request_URI ".*\.js$" p_w_picpath-request
SetEnvIf Request_URI ".*\.css$" p_w_picpath-request 
ErrorLog "logs/test.com-error_log"
CustomLog "|/usr/local/apache2/bin/rotatelogs -l 

/usr/local/apache2/logs/test.com-access_%Y%m%d_log 86400" combined env=!p_w_picpath-request


//Request_URI 是一个变量名。//env=!p_w_picpath-request取一个反义,不记录p_w_picpath-request

apache不记录指定文件类型日志_第1张图片

[root@No logs]# apachectl -t

Syntax OK

[root@No logs]# apachectl graceful

 

再次刷新一下网页,然后去去看日志就不在记录以.gif  .jpg  .png等。