tags:

views:

147

answers:

2

I'd like to easily access the logs of a server to interpret them in a way and display that data to a website visitor. How can PHP access the HTTP logs of a server and all data therein?

+2  A: 

Easiest way: create a symbolic link from /var/log/apache2/{acces,error,...}.log to a readable dir, e.g: /var/www

erenon
+3  A: 

The server logs are generally just a file that you can read and parse as any other file. Reading it line by line and using split or a regular expression are commonly done.

These can get quite large, though, so it's not unusual to have a separate process that runs once a day or an hour or whatever that updates a summary file, which would then be read by your PHP script. Or often the separate process generates static HTML pages that then just get served. There are many log analyzers that work this way.

Curt Sampson