Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.4.x] Fixed #17069 -- Added log filter example to docs.

Backport of e06189f from master.
  • Loading branch information...
commit 4b8c6c405619f7624847a469304e0d1cea053f19 1 parent 27c2ccc
@timgraham timgraham authored
Showing with 29 additions and 0 deletions.
  1. +29 −0 docs/topics/logging.txt
View
29 docs/topics/logging.txt
@@ -516,6 +516,35 @@ logging module.
through the filter. Handling of that record will not proceed if the callback
returns False.
+ For instance, to filter out :class:`~django.http.UnreadablePostError`
+ (raised when a user cancels an upload) from the admin emails, you would
+ create a filter function::
+
+ from django.http import UnreadablePostError
+
+ def skip_unreadable_post(record):
+ if record.exc_info:
+ exc_type, exc_value = record.exc_info[:2]
+ if isinstance(exc_value, UnreadablePostError):
+ return False
+ return True
+
+ and then add it to your logging config::
+
+ 'filters': {
+ 'skip_unreadable_posts': {
+ '()': 'django.utils.log.CallbackFilter',
+ 'callback': skip_unreadable_post,
+ }
+ },
+ 'handlers': {
+ 'mail_admins': {
+ 'level': 'ERROR',
+ 'filters': ['skip_unreadable_posts'],
+ 'class': 'django.utils.log.AdminEmailHandler'
+ }
+ },
+
.. class:: RequireDebugFalse()
.. versionadded:: 1.4
Please sign in to comment.
Something went wrong with that request. Please try again.