dontlog Apache 2.4

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

projectsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony GarciaDevops StaffCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
projectsAuthor 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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.