dontlog Apache 2.4

projects
projects used Ask the Experts™
on
Looking all over the net, cannot find a solution that works. What's wrong with the following as it doesn't prevent the logging I am trying to stop.

ErrorLog "logs/error_log"
LogLevel warn

<IfModule log_config_module>
        LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
        SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
        SetEnvIf Remote_Addr "::1" dontlog
        SetEnvIf Remote_Addr "1\.2\.3\.4" dontlog
        SetEnvIf Remote_Addr "5\.6\.7\.8" dontlog
        SetEnvIf User-Agent ".*internal dummy connection.*" dontlog
        CustomLog /var/log/httpd/access_log combined env=!dontlog
        CustomLog /var/log/httpd/access_log combined
        ErrorLog  /var/log/httpd/error_log
    <IfModule logio_module>
        LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
        CustomLog "logs/access_log" combined
</IfModule>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Devops Staff
Commented:
CustomLog /var/log/httpd/access_log combined env=!dontlog
CustomLog /var/log/httpd/access_log combined

Open in new window

You are declaring the CustomLog statement twice, and again towards the end all writing to the same file. If you remove the last two that don't have the env=!dontlog conditional you should see the behavior you want. These statements are making it so you are writing everything to this file.

You are also declaring the ErrorLog directive twice. Lastly, it does not seem you are using the combinedio LogFormat so you are safe to remove this.
    <IfModule logio_module>
        LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

Open in new window

Author

Commented:
>CustomLog statement twice

Ooops, that was a typo, left in there from the last edit.
Edited and working now, thanks for catching that. Sometimes you stare at something too long and you don't see the obvious.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial