How to Enable PHP Error Log

There are two methods for viewing PHP errors that occur while running your website. You can either display errors directly on your website (viewable from any web browser) or enable error logging to write the errors to a specified file (viewable inside a text file). You can configure this on php.ini directly.

Displaying on Website

For viewing errors on the website front end, you can add the following to php.ini.

Specify which errors to show. All errors, but not notices:

error_reporting = E_ALL & ~E_NOTICE

or all errors, including notices:

error_reporting = E_ALL

Next, specify that you want errors to be displayed:

display_errors = On

Writing to File

To write the errors to a specified file, you can add the following to php.ini.

Set the following line of code to On to log errors, or Off to turn error logging off:

log_errors = On

Next, save errors from any page to a specific location, error_log in the document root, in this example.

error_log = error_log
 
litespeed_wiki/php/enable-php-error_log.txt · Last modified: 2018/07/06 13:44 by Lisa Clarke