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?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
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.
Easiest way: create a symbolic link from /var/log/apache2/{acces,error,...}.log to a readable dir, e.g: /var/www