在单独的文件中记录特定请求

时间:2012-09-26 17:30:33

标签: apache .htaccess

我想记录针对特定文件的请求,比如使用.htaccess将collect.gif写入单独的日志文件中,这是可以实现的吗?

E.g http://www.domain.com/collect.gif?user=1&page=sample必须单独登录到文件collect.log

1 个答案:

答案 0 :(得分:2)

几乎完全涵盖CustomLog sectionApache documentation。在此复制相关部分:

SetEnvIf Request_URI \.gif$ gif-image
CustomLog gif-requests.log common env=gif-image
CustomLog nongif-requests.log common env=!gif-image

因此,根据您的情况,您只需更改SetEnvIf条件以匹配您之后的请求:

SetEnvIf Request_URI collect\.gif$ gif-image
CustomLog gif-requests.log common env=gif-image
CustomLog nongif-requests.log common env=!gif-image