Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn on error messages in magento 2

Tags:

I have installed magento 2 and it working.I just created the Hello world module and it working now.

My issue was I had called non existing method in execute method.

While trying to get it to work I tried to load the page it shows blank white screen, but no error.

How do I get errors to display in magento2?

like image 624
Ranjit Shinde Avatar asked Jan 06 '16 09:01

Ranjit Shinde


People also ask

How to add error message in Magento 2?

$this->messageManager->addNotice(__("Notice")); $this->messageManager->addSuccess(__("Success")); To customize them, you have to replace Error, Warning, Notice, and Success with a new message.

Where is Magento error log?

Find the errors log file in Magento x website they are located in the <magento-folder>/var/log/ folder.


2 Answers

Add following code in index.php file :-

error_reporting(E_ALL); ini_set('display_errors', 1); 
like image 182
Pratik Oza Avatar answered Sep 30 '22 07:09

Pratik Oza


Enabling Error reporting in magento2 is little tricky , as magento2 now comes with 3 different modes

  1. Default
  2. Developer
  3. Production

Magento2 by default install in “default” mode and thats why you dont get the error log at the front-end of the site , that can a viewed at magento error log . You may check the complete details over here http://devdocs.magento.com/guides/v2.0/config-guide/bootstrap/magento-modes.html

How to enable developer mode in Magento2

This is must have if you are a developer and building extension and template for magento2 , magento provide a command for this purpose . Login in to your linux terminal and under magento execute

php bin/magento deploy:mode:set developer 

and it will enable the developer mode under your magento instance for production mode you can set the mode to production or default .

still if you are experiencing in error reporting

you can give a try by renaming local.xml.sample to local.xml under pub/errors

like image 40
webkul Avatar answered Sep 30 '22 07:09

webkul