我在虚拟主机中有这条线:
CustomLog /var/log/access.log combined
但是我想要一个特定的日志来写每个特定目录的请求
例如
我在公众中有这个子目录:
user@/var/www # ls index.test images/ test.php
如何写一个日志,当用户提出请求任何文件内的images目录?
编辑:这主要的想法是防止主日志文件增长很多,并简化search
你可以尝试设置环境variables。
例如。
SetEnvIf Request_URI ^/images(/|$) imageslog CustomLog /var/log/images-access.log combined env=imageslog
第三个参数是可选的,并根据服务器环境中特定variables的存在或不存在来控制是否logging特定的请求。 如果为请求设置了指定的环境variables(或者未设置,如果是
'env=!name'子句),则会logging该请求。环境variables可以使用
mod_setenvif和/或mod_rewrite模块在每个请求的基础上进行设置。 例如,如果要将服务器上所有GIF图像的请求logging在单独的日志文件中,但不logging在主日志中,则可以使用:SetEnvIf Request_URI \.gif$ gif-image CustomLog gif-requests.log common env=gif-image CustomLog nongif-requests.log common env=!gif-image或者,要重现旧的RefererIgnore指令的行为,可以使用以下内容:
SetEnvIf Referer example\.com localreferer CustomLog referer.log referer env=!localreferer
另见: http : //httpd.apache.org/docs/2.2/mod/mod_log_config.html
我希望这个帮助