Presenting Mathematical Concepts on the World Wide Web
Think Big: Designing a Web Site

Discover Your Audience:
A Sample Page Logger

One way to set up page logging (one way we do it at the Geometry Center) will be described here. You will likely need some extra information or assistance to make this approach work at your site.

In most cases, this form of logging will involve a three-step process:


  1. Make an executable perl script called logger (and use chmod +x filename, if needed). It should contain the following code:

        #! /usr/local/bin/perl
    
        $machine = $ENV{REMOTE_HOST};
        $date    = $ENV{DATE_LOCAL};
        $agent   = $ENV{HTTP_USER_AGENT};
        $referer = $ENV{HTTP_REFERER};
        $referer = "*unknown*" if ($referer eq "");
    
        $month{'Jan'} = 1;
        $month{'Feb'} = 2;
        $month{'Mar'} = 3;
        $month{'Apr'} = 4;
        $month{'May'} = 5;
        $month{'Jun'} = 6;
        $month{'Jul'} = 7;
        $month{'Aug'} = 8;
        $month{'Sep'} = 9;
        $month{'Oct'} = 10;
        $month{'Nov'} = 11;
        $month{'Dec'} = 12;
    
        ($d,$m,$y,$t) = ($date =~ m/(\d+)-([^-]+)-(\d+)\s+(\d\d:\d\d:\d\d)/);
        $date = sprintf("%02d-%02d-%02d",$y,$month{$m},$d)." ".$t;
    
        print($date," ",$machine," [",$referer,"] [",$agent,"]\n");
    

  2. Insert a line at the top of your HTML file like the following:

        <!--#exec cmd="./logger >> usage.log" -->
    

  3. Finally, make an .htaccess file starting with the lines

        Options Includes
        AddType text/x-server-parsed-html filename
    
    where filename is the name of the .html file that you want to log.


Next: Sample Graphs
Back: A Sample Page-Hits Log
Up: Think Big: Designing a Web Site


Presenting Mathematical Concepts on the World Wide Web. Copyright © 1997 by Carol Scheftic. All rights reserved. (This course is based on a workshop originally offered at The Geometry Center and adapted with permission.) Please send comments on this page, or requests for permission to re-use material from this page, to: scheftic@geom.umn.edu
Page established 1-Jun-97; last updated Sunday, 13-Jul-1997 19:37:44 CDT.