Hello Magento Folks,
How are you all today?. I have come along to give you some rich knowledge about the interesting topic of Magento 2: How to Enable Error Reporting. If you are looking for a Responsive Magento Theme for your Magento 2 Store then kindly take a visit to the previous article of the Magento Tutorial series Top 10 Best Responsive Magento Themes for 2021.
Enable Magento Error Logs In Magento 2
If you are facing a problem in which your Magento store displays a plain white page, a blank page with the error numbers, 500 Internal servers or any broken content error with missing footer then to overcome this problem apply the below-given steps on your Magento 2 Store.
One of the most used Ecommerce platforms Magento has functionality that it shows the error message in various forms based on its server settings whether it is in developer mode or in production mode. If you are busy debugging any type of issue on your Magento 2 store then better is to set it in developer mode for not facing any type of inconvenience.
Enable error reporting: Displays Blank White Page.
Mainly the reason behind this is most probably the issue coming in fatal PHP error that means the PHP is not able to recover and due to the purpose of security, most of the servers are configured to hide the error message by default because it includes sensitive information. The smooth and easiest method to debug a blank page error is to get through the reason due to which issue is created.
Step 1: Firstly, you have to verify your PHP logs by connecting to your server with the help of SSH or using the c panel file. If this is not possible then you can easily contact your server hosting partner by describing the issue and generating the ticket for getting the access for your error log files.
Step 2: If there is no access to your server or you find difficulties in finding the location then you can forcefully print the error message to your browser with the help of editing your index.php file as illustrated below.
error_reporting(E_ALL); ini_set('display_errors', 1);
Eg. index.php
<?php ... error_reporting(E_ALL); ini_set('display_errors', 1); try { require DIR . '/app/bootstrap.php'; } catch (\Exception $e) { ...... }
For not displaying the sensitive information to your users, one can directly hard code their IP address so only the error message will only be displayed to the configured IP address.
$customIPAddress = ['your IP address here']; if (in_array($_SERVER["REMOTE_ADDR"], $customIPAddress) { error_reporting(E_ALL); ini_set('display_errors', 1); }
Enable error reporting: Displays Blank White Page With Error Message
Step: For the error displayed above you can easily perform by visiting ssh into your web server, and can navigate to your Magento 2 root folder/var/report then read the file name and view the error message respectively.
Enable error reporting: Broken Content with Missing Footer
When there is any issue regarding the content of the page then automatically PHP encounters the error and the PHP stops working. To overcome this you have to firstly open the debug view on your browser and after that scroll down and verify whether there is any error information displayed or not. If the error is not displayed then you have to enable the option of error reporting and try again.
Step 1: Check php error / apache / NGINX error log files in the /var/log/ folder
Step 2: Check your Magento 2 error folder in Magento root var folder (var/report/*, var/log/debug.log, var/: exception.log and system.log)
Step 3: Check your Magento mode (default, developer or production)
Step 4: Check your server php error log setting
Final Words
Therefore, by implementing the above-given steps, you will be able to successfully enable the error reporting in Magento 2. If you find any difficulties in implementing the above-given steps then you can feel free to contact our Support Team who will guide you regarding this.
If you find the article is full of rich knowledge then do share with your Magento friends and comment down your views regarding the article. Also, comment down if you want me to solve any problems you are facing. Till then stay home and stay safe.
Happy Reading