How to trigger an email alert when my app encountering internal errors?

Solution 1:

The logging tool helps in identification of root cause or narrowing down a fix based on the Heroku app, database logs. You can install a Heroku add-on and setup a logging tool. Here are few logging tools in https://elements.heroku.com/addons#logging with different set of features that you can set, integrate as per your use case.

enter image description here

The logging add-on shall enable you in reaching near to the root cause based on the logs/details gathered, however for error or exception notification, the add-on should have the related notification service that can be integrated with your application or should parse the logfiles to store and track when exceptions happen such that they can be parsed/configured to send emails or other types of notifications. New Relic can be one such thing that can be checked.