You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by UniCapitals <ca...@gmail.com> on 2018/11/15 08:24:58 UTC

[users@httpd] Apache 2.4 how to exclude certain GET requests from log using SetEnvIf

Hello to Apache Community,
I spent time with Apache docs and Google but did not find any real example for that.

I want to exclude from logging many unnecessary lines like that

83.266.84.27 - - [27/Oct/2018:14:07:19 -0500] "GET example.com/mod/maxtop.php HTTP/1.1" 200 3412 "http://example.com/page218.html" "Mozilla/5.0 (Windows NT 10.0; rv:56.0) Gecko/20100101 Firefox/56.0"

I tried
SetEnvIf Request_Method GET "^/maxtop\.php$" dontlog
and
SetEnvIf Request_Method "GET(.*)/maxtop\.php$" dontlog
...but no success.

Additional info
CentOS 7.5
Server version: Apache/2.4.6 (CentOS)
LogFormat "%h %l %u %t \"%m %V%U %H\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined

Thx for any hint what else to try (if Apache GET exclude by regex at all possible...)

Serge

Re: [users@httpd] Apache 2.4 how to exclude certain GET requests from log using SetEnvIf

Posted by Yehuda Katz <ye...@ymkatz.net>.
You need to specify an env= (or !=) On the LogFormat line. There is nothing
magic about setting dontlog.

- Y

Sent from a device with a very small keyboard and hyperactive autocorrect.

On Thu, Nov 15, 2018, 3:30 AM UniCapitals <cashnexus@gmail.com wrote:

> Hello to Apache Community,
> I spent time with Apache docs and Google but did not find any real example
> for that.
>
> I want to exclude from logging many unnecessary lines like that
>
> 83.266.84.27 - - [27/Oct/2018:14:07:19 -0500] "GET
> example.com/mod/maxtop.php HTTP/1.1" 200 3412 "
> http://example.com/page218.html" "Mozilla/5.0 (Windows NT 10.0; rv:56.0)
> Gecko/20100101 Firefox/56.0"
>
> I tried
> SetEnvIf Request_Method GET "^/maxtop\.php$" dontlog
> and
> SetEnvIf Request_Method "GET(.*)/maxtop\.php$" dontlog
> ...but no success.
>
> Additional info
> CentOS 7.5
> Server version: Apache/2.4.6 (CentOS)
> LogFormat "%h %l %u %t \"%m %V%U %H\" %>s %b \"%{Referer}i\"
> \"%{User-agent}i\"" combined
>
> Thx for any hint what else to try (if Apache GET exclude by regex at all
> possible...)
>
> Serge
>