While the
HTML-Kit Log Analyzer Pro (hkLAP) add-on can be used to analyze standard web server logs, one of its features is the ability to process log files created using its own simple log file format. Since these logs can be created in scripts written ASP, PHP, Perl, Python and other server-side scripting languages, hkLAP makes it easier to analyze custom data such as poll results, feature requests, link clicks, download counts, and more, even if web server logs are not present. This technique can be used on demand to analyze only a specific section of a site. By avoiding the need to log every request received by the web server, this method may reduce the amount of disk space required to store log files and also reduce the amount of time it takes to analyze logs.
For example, PHP developers can use the following function to create simple log files that can be analyzed using hkLAP.
<?php
function hklap_log($sLogFile, $sMyData = '', $sMyAgent = '', $sMyRef = '')
{
$sLogLine = date("m/d/Y H:i:s").", ".
$_SERVER['REMOTE_ADDR'].", ".
($sMyData ? $sMyData : $_SERVER['REQUEST_URI']).", ".
($sMyAgent ? $sMyAgent : $_SERVER['HTTP_USER_AGENT']).", ".
($sMyHost ? $sMyHost : $_SERVER['HTTP_HOST']).", ".
($sMyRef ? $sMyRef : $_SERVER['HTTP_REFERER'])."\r\n";
$file = fopen( $sLogFile, "a");
if($file)
{
flock($file, 2);
fputs($file, $sLogLine);
flock($file, 3);
fclose($file);
}
}
// log page requests:
hklap_log('mysite.log');
// add a log entry with custom data
// ($sResult contains a custom value from a script)
hklap_log('myScript.log', $sResult);
?>
The custom *.log files can then be opened in hkLAP.