Home arrow Tools arrow Content on log files via browser

Content on log files via browser

Posted Friday, 23 November 2007 by Michael Khanin
Digg!

I’ve a client that runs special program on about 100 servers. This program writes a log on central server every 3 minutes. So, when I checked main server, I found a directory Logs (C:\Logs). Log’s directory contains many log files (each log for each server).  On this server installed and runs a web server, Apache ;). So, I’d like to show a small AppsRuns.php file, which stored on web server. If we go to the http://server1/AppsRuns.php we will see a content of each log file on one web page. This web page refreshing every 10 sec. Here is a content of AppsRuns.php file: 

<?php
    $refresh_time = 10; // seconds
    $path = "C:\LOGS";

    header("Content-Type: text/plain");     header("Refresh: $refresh_time");    
    if($handle = opendir($path)) {     while (false !== ($file = readdir($handle))) {         $pi = pathinfo($path . '/' . $file);         if($pi['extension'] === 'txt') {         include($path . '/' . $file);         }     }     } ?>






Reddit!Del.icio.us!Google!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites! title=
 

Add comment

You have no rights to add a new comment. May be you need to register on the site.