How to Check Your Website’s PHP Error Log

How to Check Your Website’s PHP Error Log

Many error messages don’t give much information about what you should do to resolve it. For that reason, it is recommended to use the PHP error log, a file responsible for recording site errors and telling which specific line code that needs fixing. Keep scrolling to find out how to enable this feature!

Enabling PHP Error Logging

Before tweaking some code and settings, make sure to check whether PHP error logging is enabled on your hosting account. Open your PHP information, press CTRL + F and search for log_errors value.The value of log_errors in PHP information tool is off

If the value is set to Off, there are a few ways to turn it on depending on your hosting platform.

This article will show you how to enable error logging by adjusting some settings in Hostinger’s control panel and editing the .htaccess file

Method 1: Using hPanel

The easiest way to activate the PHP error logging is through the Hostinger’s hPanel. Follow these simple steps:

  1. Login to the hPanel and find the PHP Configurations tool, located under the Advanced section.
  2. Switch to the PHP Options tab, and tick the log_errors box. Click Save.PHP configurations on hPanel

An error log will be automatically generated in your public_html directory.

Method 2: Editing .htaccess File

If you don’t use Hostinger, PHP error logging can also be enabled by editing the .htaccess file. Read this tutorial to know how to locate the file, and then do the following steps:

    1. Create a file called error_log.txt in the public_html directory. All errors will be logged into this file.
    2. Open .htaccess and insert the following line:
      php_flag log_errors on
      php_value error_reporting 32767
      php_value error_log "error_log.txt"
    3. Click Save, and that’s it! You’ve successfully enabled PHP error logging.

When you re-check your PHP info, the Local Value should be on, while the Master Value is still off. However, pay no mind to the master value because it is overridden by the local value.The local value of log_errors in PHP info is set to On

Opening the Error Log

Now that you’ve activated the PHP error logging, any PHP error that occurs on your website will be logged into the error log file.

To test if it works, add an extra symbol to your code and refresh the site. Afterward, use File Manager to open the error log file and check if there are any new entries:

This image shows you error entries inside the error_log fileHere are some examples of common errors that can help you analyze the log entries:

  • PHP Parse error:  syntax error, unexpected ‘2’ (T_LNUMBER), expecting ‘)’ in /home/u802426761/domains/username/public_html/wp-config.php on line 54 means that there is a syntax error in your code. To fix this issue, check the file and the line number mentioned in the message.
  • PHP Fatal error: Call to undefined function get_header() in /var/www/username/public/blog/wp-content/themes/theme/index.php on line 1 warns that the index.php page is trying to call a function that does not exist. Check whether the function name is correct.
  • Fatal error: Maximum execution time of 30 seconds exceeded in /home/username/domains/ on line 737 could be resolved by modifying max_execution_time via PHP Configurations or .htaccess file. Check out our article to know how to do it.


In this quick tutorial, you’ve learned the two methods of enabling PHP error logging: tweaking the settings in hPanel and editing the .htaccess file. By using this feature, you’ll know what’s wrong with your site when it crashes unexpectedly. Pretty cool trick, right?

Leave a comment if you have any questions!

The author

Merkys M.

Merkys is a server administrator and Linux expert at Hostinger. He keeps everything up & running while tackling advanced server management issues. Besides that, he’s a big fan of blockchain technology, web development, and bodybuilding.