Table of Contents
Table of Contents
You may occasionally run into an issue with Magento 2 when a black or white page with error numbers such as Error log record number: 468837792541 or any broken content error shows.
In the default setting of Magento 2, the function which allows displaying the error on the frontend is disabled. Therefore, in today’s post, I will guide you on how to display the error message or enable error reporting on Magento 2.
How To Display The Magneto 2 Errors? Here is a tutorial to display the Magneto 2 errors.
Step 1: Modify the.htaccess file
To begin, open the.htaccess file and add the following code at the end of it:
php_value display_errors on ## enable PHP's error
display settings php_value error_reporting -1 ## set
error display to E_ALL
Once the code has been added, launch Terminal or Command Prompt and navigate to the Magento root directory.
cd /path/to/your/magento/directory
To enter developer mode, use the code below.
php bin/magento deploy:mode:set developer
This command can be used to verify the deploy mode that is currently in use:
php bin/magento deploy:mode:show
Clear the cache:
php bin/magento cache:clean
When you surf your Magento website after correctly completing all of the aforementioned procedures, the error message will appear on the browser itself. However, this is just advantageous for the development environment, just like the previous method.
First, go to the root directory of your Magento installation.
Next, launch the app/bootstrap.php file.
This code appears at the begin:
#ini_set('display_errors', 1);
After you’ve seen it, kindly change the code to:
error_reporting(E_ALL); # Set Error Reporting as E_ALL (Report all PHP errors)
ini_set('display_errors', 1); # Un-commenting this line to enable PHP error display
Once the code has been updated, launch Terminal or Command Prompt and navigate to the Magento root directory.
cd /path/to/your/magento/directory
Activate developer mode.
php bin/magento deploy:mode:set developer
You can use the line below to see what deploy mode is currently in use:
php bin/magento deploy:mode:show
Finally, clear the Cache:
php bin/magento cache:clean
That’s it. The browser will display error messages once you have correctly completed all of the aforementioned stages.
This lesson will be helpful if you have ever run into a Magento 2 error or if your website’s storefront displays a blank page. There is little chance of making a mistake because the process is rather straightforward. Continue reading if you’re willing to solve this issue.