0

I'm logging in access.log combined. Here is my apache2.conf part about Log

CustomLog ${APACHE_LOG_DIR}/access.log combined
LogFormat "%!200h %!200l %!200u %!200t \"%!200r\" %!200>s %!200O \"%!200{Referer}i\" \"%!200{User-Agent}i\"" combined

I added the !200 to prevent logging all 200 code but it's not working. It still log - - - - "-" - - "-" "-"

Any Idea how to stop apache from Logging OK 200 but log everything else.

I try googling a lot and the only thing I can found is on the official Apache Page.

https://httpd.apache.org/docs/2.4/en/logs.html

1

After a log of googling I found that you can add this at the end of the line when you declare your custom Log.

"expr=%{REQUEST_STATUS} > 200"

It will log if the status is higher then 200

You can customize this for your need.

"expr=%{REQUEST_STATUS} >= 400"

My final config is :

CustomLog ${APACHE_LOG_DIR}/access.log combined "expr=%{REQUEST_STATUS} > 200"
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

The answer was found here : Prevent logging of 400 errors in Apache httpd

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.