3

I googled out how to apply error reporting in Magento 2, but I didn't find any solution yet. It will be useful if there is any link.

3 Answers 3

5

By default Error reporting are possible in frontend using developer mode.

Run command,

Using Developer mode, you can directly check error in frontend browser if any error are occur,

php bin/magento deploy:mode:set developer

Changes in file,

Go To pub folder of root and rename at below path,

pub/erros/local.xml.sample to local.xml

Now go to app/bootstrap.php file,

Remove # from initial,

#ini_set('display_errors', 1);

to

ini_set('display_errors', 1);

4
  • How can i mail these errors. Is it possible or not @Rakesh ? Commented Nov 7, 2016 at 12:46
  • sorry, what do you want to do? Commented Nov 7, 2016 at 12:47
  • I want to send exceptions and logs in email while any error triggered in my mageto 2 setup. Can i do this ? Commented Nov 7, 2016 at 12:50
  • hm, obviously look in magento/var/log no need to mess with ini_set ...
    – MagenX
    Commented Nov 8, 2016 at 19:19
1

You can set the developer mode on by using following command:

php bin/magento deploy:mode:set developer

It should enable error reporting. When your purpose is done return back to default mode. If you are still not able to find error reporting, then you may add following lines in app/bootstrap.php:

error_reporting(E_ALL);
ini_set('display_errors', 1);
2
  • I would like to mail errors in email. Can i do this ? Commented Nov 7, 2016 at 12:40
  • What type of server is your Magento 2 on? If in Linux I know mine is stored in /var/logs/mail.log this is in the root of the server, not Magento for me. You should check which mail service your server is using. (I use sendmail by default)
    – camdixon
    Commented Nov 7, 2016 at 12:44
0

In app/bootstrap.php have:

error_reporting(E_ALL);
ini_set('display_errors', 1)

And be in developer mode.

https://github.com/magento/magento2/blob/develop/app/bootstrap.php

Depending on your server setup apache/nginx/php it would be useful to log all errors to catch Ajax and cron php errors. All this is for debugging purpose only.

If you're talking about exceptions not being displayed in the page, maybe you have local.xml in pub/errors https://github.com/magento/magento2/tree/develop/pub/errors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.