Exclude requests from own IPs in clients' logs

Discussion in 'Tips/Tricks/Mods' started by meemu, May 18, 2007.

  1. meemu

    meemu New Member

    I noticed after a transferring a site from our old web server to the new ISPConfig one that webalizer almost showed twice as many hits as before. So looked at the logs and realised that this was caused by subrequest - the site is heavily using SSI includes. To not log this and not include it in the traffic stats I made this little change to /root/ispconfig/scripts/shell/logs.php. It's a diff against the latest SVN version but also works for older versions (the one I was actually using was ISPConfig-2.2.11).

    Hope someone finds this useful.

    Code:
    43a44
    >
    75,84d75
    <
    <               /// hack to exclude requests from own IP
    <               ///
    <               list($ip) = explode(" ",$normal_log,2);
    <               //var_dump($ip);
    <               if(in_array($ip,$go_info["isp"]["server_conf"]["ips"])) {
    <                       continue;
    <               }
    <               /// end of hack
    <
    166c157
    < ?>
    ---
    > ?>
    \ No newline at end of file
    
     
  2. falko

    falko Super Moderator Howtoforge Staff

    You can tell Apache to not log hits to specific files. Put something like this into your vhost configuration:

    Code:
    SetEnvIf        Request_URI "^\/somedir\/somefile.html$" dontlog
    where somedir/somefile.html is the file (relative to the vhost's document root) that shouldn't be logged in Apache's access log.

    And then you add
    Code:
    env=!dontlog
    at the end of your CustomLog directive, e.g.
    Code:
    CustomLog "|/usr/bin/cronolog --symlink=/var/log/httpd/access.log /var/log/httpd/access.log_%Y_%m_%d" combined env=!dontlog
     
  3. meemu

    meemu New Member

    The patch is for excluding requests *from* the machine's IP (e.g. subrequests from SSI)
     

Share This Page