Enable PHP error logging to capture and review errors generated by your website's scripts. This process allows you to identify the specific files and lines of code causing issues on your website.
Before you begin
You will need:
Access to your hosting control panel (such as cPanel or Windows Control Panel)
Access to the file manager or an FTP client
A website hosted on a Hostek account
Enable PHP error logging
To enable logging, you must configure the PHP environment to record errors to a file rather than displaying them directly on the screen.
Log in to your hosting control panel.
Locate the Select PHP Version, MultiPHP INI Editor or PHP Selector tool.
Select the Options tab or click on PHP Settings.
Locate the
log_errorsdirective and set it to On.Locate the
error_logdirective. Ensure it points to a valid path, such as/home/username/public_html/error_log.Click Save or Apply.
How to find and read the log
Once logging is enabled, you can locate the generated file to diagnose issues.
Log in to your hosting control panel.
Open the File Manager.
Navigate to the directory where your website is located (typically
public_html).Look for a file named
error_log.Select the file and choose Edit or Download to view the contents.
How to display PHP errors temporarily during development
If you are actively developing a site and need to see errors immediately on the page, you can temporarily enable display errors.
Warning: Do not leave error reporting enabled on a live production website, as it can expose sensitive information about your server configuration and file paths to the public.
Open your website's main configuration file (e.g.,
index.php,wp-config.php, or a specific configuration file for your application).Add or modify the following lines of code:
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);Save the file and refresh your website to see the errors displayed on the page.
Once you have identified the issue, remove these lines or set
display_errorsto0.
How to stop displaying PHP errors on a production website
To ensure your site remains secure and professional, you should disable the public display of errors.
Log in to your hosting control panel.
Navigate to Select PHP Version or PHP Selector.
Select the Options tab.
Locate the
display_errorsdirective and set it to Off.Click Save or Apply.
Troubleshooting
The error_log file is empty or does not exist. If the error_log file is not being created, the log_errors directive may be disabled or the path in the error_log directive may be incorrect. Verify that log_errors is set to On in your PHP settings.
I see a "White Screen of Death" (blank page). A blank page often indicates a fatal PHP error that is being caught by the server but is not being displayed. Enabling PHP error logging as described in the first section of this article will allow you to see the specific error in the error_log file.
