See: Authentication, Authorization, and Access Control for information on using digest authentication.
To use, place this script in your Apache log directory. In OS X that would be /private/var/log/httpd
<?php $logs = array(); if ($handle = opendir(getcwd())) { while (false !== ($file = readdir($handle))) { if (eregi("_log$",$file)) { array_push($logs,$file); } } closedir($handle); } extract($_GET); echo"<form action='".$_SERVER['PHP_SELF']."' method='get' name='search'> Search for: <input type='text' name='text' value='$text' /> in: <select name='file'> <option value=''>Select a file</option>\n"; $n = 0; while ($n<count($logs)) { if ($logs[$n]==$file) { echo"<option value='$logs[$n]' selected='selected'>$logs[$n]</option>\n"; } else { echo"<option value='$logs[$n]'>$logs[$n]</option>"; } ++$n; } echo"</select> ;<input type='submit' name='go' value='Go' /></form> <br />\n"; if ($go) { echo"<pre>"; system("grep -i '$text' ".getcwd()."/$file",$find) or die("No matches"); echo"</pre>"; } ?>
You can also use zgrep to search the gzipped, rotated log files.
Now to serve it up. Find this line in /etc/httpd/httpd.conf
<IfModule mod_alias.c>
Under that, add these lines (where "/log/" can and should be something else that you choose).
Alias /log/ "/private/var/log/httpd/" <Directory "/private/var/log/httpd"> AuthName "realm" AuthType Digest AuthDigestFile /path/to/digestpassDBfile Require valid-user Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory>
Restart Apache: sudo apachectl graceful
Point your browser to http://yourhost/logs/ and search away! ;)

