November 4, 2019
November 4, 2019
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!
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.
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
The easiest way to activate the PHP error logging is through the Hostinger’s hPanel. Follow these simple steps:
An error log will be automatically generated in your public_html directory.
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:
php_flag log_errors on php_value error_reporting 32767 php_value error_log "error_log.txt"
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.
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:
Here are some examples of common errors that can help you analyze the log entries:
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!
August 12 2020
Hi Mr.Merkys I got this error PHP Notice: Undefined variable: subject in /home/u776963563/domains/esylearn.in/public_html/index.php on line 115 i cant open login.php on my website , please advice Regards Beula
Replied on November 06 2020
Hey Beula. In these case I'd recommend that you access your website via your file manager. If you are hosting here at Hostinger, you can find your file manager here! Once you do that you can navigate to your index.php and check the code :)
November 29 2020
Hello there, I can't find such file 'error_log' in the public_html directory. ( I have enabled the error logging ) Hostinger is my host provider. How can I find the 'error_log'?
Replied on February 09 2021
Hi, Stela! In order for error_log file to be created, an error must first be detected. If there wasn't any error detected from the moment you enabled error logging, the file wouldn't create. If you're still not able to resolve your issue, don't hesitate to contact our Customer Success team - they'll be happy to give you a hand on this!