如何在Apache Log Wiewer中只显示一些请求?

时间:2016-07-15 09:34:53

标签: regex apache logging

我只想显示那些与图片文件无关的请求(例如.png.jpg文件)。我尝试在自定义日志字段中使用正则表达式:

LogFormat "%h %l %u %t \"%r\/^((?!png).)*$/s" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined

然而它没有用。

1 个答案:

答案 0 :(得分:0)

您无法使用LogFormat指令,而是使用CustomLog

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
SetEnvIf Request_URI \.(gif|png)$ is-image
CustomLog "/path/to/logs/requests.log" combined env=!is-image