Enable Error Reporting in Magento 2

0

When you are developing in Magento 2, you often come across errors that you can’t “spot” easily. The error log in Magento 2 helps you enormously in finding errors in the code. Unfortunately, in Magento 2, error reporting is a little bit different then Magento 1. In this article, we’ll explain how to enable error messages in M2 so you can fix all bugs and see if your code runs smoothly.

Magento 2 comes with 3 different modes. They are Default, Developer & Production. Each of the modes is tied to the stage your ecommerce store is in. After you’ve installed Magento 2, the store is in the “default” mode, which does not do error reporting. You need to enable the “developer” mode in Magento 2 to get error reporting working. You can do this as follows.

Log in to your terminal/ssh client and navigate to the root of your M2 installation. Then, execute the following command.

This will tell your M2 installation to switch to the developer mode and to enable developer help tools like error reporting. After you’re done developing, feel free to switch the mode back to production.

To check which mode your Magento 2 installation currently use, execute the following command in the SSH/command line tool.

Alternatively, if your M2 installation is already in developer mode, and you still can’t see error logs, you can try to add the following code to the index.php file.

These simple solutions should help you with your development efforts in Magento 2. If you have any questions, feel free to drop a comment below.

Share.

Leave A Reply