Is there a way to view the PHP error logs or Apache error logs in a web browser?
I find it inconvenient to ssh into multiple servers and run a "tail" command to follow the error logs. Is there some tool (preferably open source) that shows me the error logs online (streaming or non-streaming?
Thanks
Look for the entry Configuration File (php. Find the Error handling and logging section of the php. ini file. Make sure that both display_errors = On, display_startup_errors = On and log_errors = On are present and uncommented. Check the value of error_log - this tells you the location of the file errors are logged to.
On a Linux server, you can access Apache error logs from var/log/apache2/error. log. You can then log out the errors from the error log file by writing the following command: sudo tail -f /var/log/apache2/error.
/var/log/apache.
Access Windows Error Logs via the Run command Launch the Run dialog box by simultaneously pressing the Windows key and the R key from your keyboard; In the newly launched Run windows, type in eventvwr; Hit Enter to run the command; And the Event Viewer window should automatically pop up right after that.
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
Since everyone is suggesting clarity, I would also like to mention tailon. I wrote tailon as a more modern and secure alternative to clarity. It's still in its early stages of development, but the functionality you need is there. You may also use wtee, if you're only interested in following a single log file.
See What commercial and open source competitors are there to Splunk? and I would recommend https://github.com/tobi/clarity
Simple and easy tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With