Prevent (stop) Apache from logging specific AJAX / XmlHttpRequests?

Go To StackoverFlow.com

5

I'm working on a site where the main idea is to do a lot of xmlHttpRequests in a loop (or loop like construct). But the thing is that every time I access the file on my server from the javascript it is logged in access log on the server. Over time the access log file gets so big it slows down the further requests.

Is there a way to tell the apache (I guess) not to log the access to this file if its correct? (I'm sending a get with a password (always different) to this file.) The access to the file will be from different IPs. I don't want to stop all the logging, just the "approved" one.

2012-04-03 22:21
by Martin Šajna
I've never heard of logging getting slow because the log file is too big - Gabe 2012-04-03 22:32
try doing over 20 accesses per second lets say 15 minutes with no break... the access log file gets big.. - Martin Šajna 2012-04-03 23:29
I'm not denying that the log will get big (although 20 lines per second doesn't sound like too much), just that I don't see how a big log file will slow down a web server - Gabe 2012-04-04 06:47


9

No problem. Just look at the example from Apache's documentation (a place where you might want to look, if you happen to have an apache-related question in the future). For example:

# Mark requests for the AJAX call
SetEnvIf Request_URI "^/myajaxscript\.php.*$" dontlog
SetEnvIf Request_URI "^/myotherajaxscript\.php$" dontlog
# Log what remains
CustomLog logs/access_log common env=!dontlog
2012-04-03 22:31
by Carsten
I read the Apache documentation and understand your comment, but what if I just want to prevent logging of a .php script without setting up a new CustomLog? My site is on Hostgator and I don't know or want to change the rest of the access log setup. Is it possible to just add a condition - JohnnyBeGood 2017-08-18 10:44
Ads