Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 318
eric Avatar asked Oct 30 '11 19:10

eric


People also ask

How do I view PHP error logs?

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.

How do I find the Apache error log?

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.

Where are PHP error logs Apache?

/var/log/apache.

How do I view the error log?

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.


3 Answers

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

like image 176
B.S.B. Avatar answered Oct 20 '22 21:10

B.S.B.


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.

like image 33
gvalkov Avatar answered Oct 20 '22 19:10

gvalkov


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

Simple and easy tool.

like image 30
Petr Avatar answered Oct 20 '22 20:10

Petr