访问日志只需要记地址,不用记录图片。
对无用的图片日志做标记,针对标记做限制。打开
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
把
ErrorLog "logs/denny.com-error_log" CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/denny.com-access_%Y%m%d_log 86400" combined
改成
SetEnvIf Request_URI ".*.gif$" image-request SetEnvIf Request_URI ".*.jpg$" image-request SetEnvIf Request_URI ".*.png$" image-request SetEnvIf Request_URI ".*.bmp$" image-request SetEnvIf Request_URI ".*.swf$" image-request SetEnvIf Request_URI ".*.js$" image-request SetEnvIf Request_URI ".*.css$" image-request ErrorLog "logs/denny.com-error_log" CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/denny.com-access_%Y%m%d_log 86400" combined env=!image-request
查看文件是否正确,重启。
apachectl -t
/usr/local/apache2/bin/apachectl restart
查看日志
less /usr/local/apache2/logs/denny.com-access_20151209_log
查看文件是否正确