LAMP 2.1Apache不记录指定文件类型日志

访问日志只需要记地址,不用记录图片。

对无用的图片日志做标记,针对标记做限制。打开

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 

查看文件是否正确

原文地址:https://www.cnblogs.com/wangshaojun/p/5031167.html