Turn On Error Messages In Magento 2
How to turn on Error Messages In Magento 2 – Error Reporting is very importtant for any framework, it helps us to track the errors during development. Here in this article we are going to explain how you can enable error messages in Magento 2.
Turn On Error Messages In Magento 2 | Enable Error Reporting
It is a little bit different to enable error reporting in magento.
.There are following methods to enables errors.
Method 1 : Set Developer Mode
To enable the error messages to show on frontend, backend you need to set the Developer Mode. Here is the following command to set the developer mode –
Magento 2 Enable Error Reporting | Set Developer Mode Example:
php bin/magento deploy:mode:set developer |
Now you will be able to see the errors occurred.
Method 2: Using Traditional Method
Alternatively you can add the following lines of code to the index.php to enable the erros & warnings.
Enable Erros & Warning Using Index.php Example:
error_reporting(E_ALL); ini_set('display_errors', 1); |
Magento 2 Modes
Primarily Magento 2 provides the following modes which can be used easily for various stages of a project. Let us look at the modes available-
- Default Mode– When you install fresh magento 2 it sets the default mode it means error will not be displayed on front end but errors can be seen in Magento error log.
- Developer Mode– If you enable the develpoer mode frontend errors will also be displayed.
- Production Mode– If you set the production mode then the errors and warnings will not be generated.
Show Current Mode
If you want to see the current mode run the following command-
Magento 2 Show Current Mode CLI Example:
bin/magento deploy:mode:show |
The above command shows the current mode instance.
Advertisements