Ratlog

Support this web site by purchasing from one of our Amazon affiliate stores:
Canada | France | Germany | Japan | United Kingdom | United States



The current version number is: 2.020323

Creates daily log files in standard NCSA combined format using server side includes. All you need is access to run cgi scripts on your server and a little bit of common sense. The beauty of this script and why I wrote it is that it creates log files in an accepted standard format (including remote host, date and time, page requested, bytes sent, referer, browser and operating system) so that you can use any standard log analysis program.


Get the code by clicking here.
Save this cgi as ratlog.cgi in your cgi-bin directory and mark it as executable
chmod 755 ratlog.cgi

Check the first line in it and make sure it points to the proper location of PERL on your server
#!/usr/local/bin/perl

Create a directory for the script to write the pages in. I use a directory off the server root called ratlog
mkdir ratlog
Then edit the script if necessary to point to that directory
$logfilepath = "../ratlog/";

include in pages you wish to log:
<!--#include virtual="/cgi-bin/ratlog.cgi" -->

or even better you can include after ratlog.cgi a question mark and then the bytes sent
For instance i went to http://www.netmechanic.com and had it scan my site, it gave me the total page sizes. My front page was 9741 bytes, so on that page I used:
<!--#include virtual="/cgi-bin/ratlog.cgi?9741" -->

I have also added error logging but this only works with Apache and if your host allows override. Just try it, if it doesn't work it won't break anything.
If you don't already have a .htaccess file in the root create one and place in it the following line:
ErrorDocument 404 /cgi-bin/ratlog.cgi
404 is the HTTP error code for file not found, you can log any error 400 or over.


You can subscribe/unsubscribe to our Scripts Announce list here.
You can discuss this script at MrRat's Scripts Support Forum


Rate this Script a 10 at CGI Extremes



The free log analysis program I recommend is AWStats.

The shareware program I recommend is Wusage, this is a great program and well worth the money.

More than you ever wanted to know about SSI can be found at Apache.org.




Updates


By popular demand I have created a version that can be used WITHOUT SSI! It is called with a simple Img Src command. Now if your hosting company doesn't allow SSI you can use the ImgSrc version.

Pros: No SSI and Simpler to Use
Cons: No Bytes Sent or Referer

Download the ImgSrc verion here.
You're Welcome.



032302: Changed the script to use #include virtual which records bytes more reliably.

072201: I added error logging to the regular script for Apache servers.


Home | Scripts | Freebies | Coupons | Gaming | Forums | Unix to Windows | Gallery | Store | Press