Stop Apache to log certain strings to access_log - possible? [SOLVED]

5 posts / 0 new
Last post
#1 Thu, 08/11/2011 - 19:12

Stop Apache to log certain strings to access_log - possible? [SOLVED]

Is it possible to stop Apache logging certain strings in to apache_log file? (i.e. certain IP address?)
(We've got some live online support system and it keeps sending traffic backwards and forwards from our own LAN and logs are full of those POST/GET requests), log files are massive in size.
I've heard it could be done via "SetEnvIf" directive in Apache somehow?
Can someone please point me in some direction, give an example how to do it? Is it Webmin or Virtualmin setting? This particular server is on Virtualmin/Webmin GPL version.
Appreciate your time and support.

Sat, 08/13/2011 - 23:09


Well, if a change like that would work, it would be something that you'd change in Apache itself, rather than a Webmin/Virtualmin setting.

However, I'm not sure how to accomplish it :-)

Reviewing the SetEnvIf documentation here:

I do see a way to have it test for a particular IP address, but I don't see a way to have it change VirtualHost settings, including filtering logs, based on that criteria.

That said, now that I do a little Googling, I do see some examples that show how it may work.

If you were to edit your Apache config, and add something like this to the VirtualHost block for the domain in question, it might do the trick :-)

SetEnvIf Remote_Addr "" dontlog

I've never tried that before, so you may need to experiment a bit, but perhaps that'll get you started.


Sun, 08/14/2011 - 16:31 (Reply to #2)

Cheers, andreychek
Here is working solution:
Go to:

Webmin - Servers - Apache Server - Edit config files - go to a website u need and find this
#original line CustomLog /home/yourwebsite/logs/access_log combined
# replace it with:
CustomLog /home/yourwebsite/logs/access_log combined env=!dontlog
# and add this line
SetEnvIf Request_URI "^/livehelp/server.php$" dontlog

I've used dontlog by URL (Request_URI)
But you can also use variables such as IP, user_agent, etc, here is full list:

I hope it helps someone in the future

Sun, 08/21/2016 - 07:26

The env=!dontlog works great! Thankls for that.

One issue though.... When I transfer a server to another virtualmin GPL server that setenv thingy is not send over. So the new server is bloating the log files again. Would be nice if it did get copied over when I do a transfer :)

Thanks, great software!


Sat, 11/05/2016 - 12:33

All what we want for the hack snap all is ready for snapchat.

Topic locked