« State of Ajax: Progress, Challenges, and Implications for SOAs | Home | Post to Blogger from within MS Word »

Creating Your Own Server Logs

By Martin English | August 21, 2005

link here.
The example given would suit a PHP based blog package like WordPress, or it could be adapted to whatever programming language is your chocie (the environment variables used have equivalents in most script languages).
The principal is that you write a little piece of code (PHP /Perl / Ruby / etc) that simply takes all the global environment variables and formats them into a suitable line for the server log, then opens the log file and appends the line to the server log. The server log is named for each day.
The next step is to include this code in all your web pages. It’s easier if you do what I did with the site I built for Suzanne Kennedy which already uses PHP to break up the pages into common header/footer/menu sections. This makes it a simple modification of one of those files to add an include to the logger.php script.
Bonus 1 - if you want to get fancy, you can make a front-end to view all your logs. Now you can browse to this page and see a list of all your server logs, click on each one to view it.
Bonus 2 - If you want to get really fancy you’d write a third PHP file that would format the server logs into HTML so you could check out who owns each IP address.
Bonus 3 - by updating the .htaccess file you can redirect 404 errors to your own PHP document that will display the 404 error and also log when misdirections occur at my site (since the requested document is in the GET request).

Topics: Uncategorized |

 
close Reblog this comment
blog comments powered by Disqus

  • Follow me via RSS



  • Search the Web safely for high quality, public domain images.






  • Recent....

  • www.flickr.com
    This is a Flickr badge showing public photos and videos from martin english (AUS). Make your own badge here.