@@ -28,6 +28,46 @@ exception to the :attr:`~flask.Flask.logger`.
28
28
But there is more you can do, and we will cover some better setups to deal
29
29
with errors.
30
30
31
+ Error Logging Tools
32
+ -------------------
33
+
34
+ Sending error mails, even if just for critical ones, can become
35
+ overwhelming if enough users are hitting the error and log files are
36
+ typically never looked at. This is why we're recommending using
37
+ `Sentry <http://www.getsentry.com/ >`_ for dealing with application errors.
38
+ It's available as an Open Source project `on GitHub
39
+ <github.com/getsentry/sentry> `__ and is also available as `Hosted Version
40
+ <https://getsentry.com/signup/> `_ which you can try for free. Sentry
41
+ aggregates duplicate erorrs, captures the full stack trace and local
42
+ variables for debugging, and send you mails based on new errors or
43
+ frequency thresholds.
44
+
45
+ To use Sentry you need to install the `raven ` client::
46
+
47
+ $ pip install raven
48
+
49
+ And then add this to your Flask app::
50
+
51
+ from raven.contrib.flask import Sentry
52
+ sentry = Sentry(app, dsn='YOUR_DSN_HERE')
53
+
54
+ Of if you are using factories you can also init it later::
55
+
56
+ from raven.contrib.flask import Sentry
57
+ sentry = Sentry(dsn='YOUR_DSN_HERE')
58
+
59
+ def create_app():
60
+ app = Flask(__name__)
61
+ sentry.init_app(app)
62
+ ...
63
+ return app
64
+
65
+ The `YOUR_DSN_HERE ` value needs to be replaced with the DSN value you get
66
+ from your Sentry installation.
67
+
68
+ Afterwards failures are automatically reported to Sentry and from there
69
+ you can receive error notifications.
70
+
31
71
.. _error-handlers :
32
72
33
73
Error handlers
0 commit comments