How To Enable PHP Error Logging


The PHP Error log is a useful way of finding and troubleshooting errors that exist on your site. Once it is enabled, any PHP errors generated by your site will be recorded in a log file.

Enable in cPanel

Step 1 - Log into cPanel and click on Select PHP Version.

e8c6466f9c4826dce993390f983a634d461be59c?t=79c95908882a5dae32be400fb812ec6d


Step 2 - Click on Switch to PHP Options.

b6ba8dee447457991f02f0f7d6d4184a71475357?t=09058d93d34ad99c49c307b60033f15b


Step 3 -
(1) Select Log_Errors.
(2) Confirm the location of the error log. In this case, it's'/home/<cPanel_Username>/public_html/error_log'.
(3) (Optional) If you would like PHP errors to display on the live site for ease of troubleshooting, select this option.

d7a42a419c9ee64c122e90b7f2a397bed13aca82?t=25631231bf0d9821cdcdc5863ece4165

Enable through .htaccess

Step 1 - Log into cPanel and click on File Manager.




Step 2 - Edit your .htaccess file and add the below code to the top.

php_flag log_errors On
php_value error_log /home/CPANELUSERNAME/public_html/error_log


Be sure to replace CPANELUSERNAME with your cPanel account's username. It should look something this:




Hit Save Changes in the top right once that's finished then click Close to close that file.



View the error log

Note: If an 'error_log' file does not exist, it will be created when a PHP error is generated. If your error log is over 10MB, it will load too slowly to be useful in troubleshooting. In this case we would recommend renaming the current log to 'error_log.CURRENTDATE' so any new errors are created in a new 'error_log' file.


Step 1 - Open the File Manager.

Step 2 - Navigate to the public_html directory. You should see a file called 'error_log'.

Note: On a VPS or Dedicated server, you might need to visit "/home/<cPanel_Username>/public_html/logs/yourdomain-com-au-error_log" instead.

a8e6a4e1ea54ee942c18f9efd9c0402cde3f312a?t=b89a469bd796c86a23271b71f7af941d



Step 3 - Right Click the Error Log and select either View or Edit. Alternatively, double-click the file to Download it, then open it in your text editor of choice.

96547aa6e0c49b91a424c517c9d8feee0449ee7c?t=c90851989c749ec5f4b88a4d75d48aa9


Finally, depending on the permissions granted to the error log, you may be able to access it publicly by visiting the site "yourdomain.net.au/error_log".



Did you find this article useful?