How to view PHP or Apache error log online in a browser?

A simple php code to read log and print:

<?php

  exec('tail /var/log/apache2/error.log', $error_logs);

  foreach($error_logs as $error_log) {

       echo "<br />".$error_log;
  }

 ?>

You can embed error_log php variable in html as per your requirement. The best part is tail command will load the latest errors which wont make too load on your server.

You can change tail to give output as you want

Ex. tail myfile.txt -n 100 // it will give last 100 lines


See What commercial and open source competitors are there to Splunk? and I would recommend https://github.com/tobi/clarity

Simple and easy tool.