#17069 closed New feature (fixed)
Extend the error logger's API to allow ignoring some errors
Reported by: | Julien Phalip | Owned by: | peppergrower |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This feature request was prompted after some discussions in #10046 and on django-dev: http://groups.google.com/group/django-developers/browse_thread/thread/71cd0bbc76113ac8
In particular, there are certain common errors like 'IOError: request data read error' which live outside of Django's or the developer's control, and which can safely be ignored. However, it can be risky to systematically ignore every IOError
in Django core as there could be other genuinely important causes for it, especially at the WSGI layer.
So, as suggested by Graham Dumpleton and others on IRC, the API for the Django's built-in error loggers could be extended to let the user specify which errors could be ignored and not be logged.
Change History (6)
comment:1 by , 13 years ago
Component: | Core (Other) → Documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | 1.3 → SVN |
comment:2 by , 13 years ago
FWIW here's the logging filter class I'm using to narrowly suppress IOError exceptions raised from _get_raw_post_data():
import sys, traceback class _SuppressUnreadablePost(object): def filter(self, record): _, exception, tb = sys.exc_info() if isinstance(exception, IOError): for _, _, function, _ in traceback.extract_tb(tb): if function == '_get_raw_post_data': return False return True
comment:3 by , 12 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
As suggested by carljm, I added a change to the docs in this pull request. Since we now have the exception class UnreadablePostError
(#17277), filtering out incomplete uploads is fairly simple and hopefully makes a good example of filtering.
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Since admin error emails are just using logging now, we essentially have this feature already: all it takes is writing a custom Filter and adding it to your logging config. So I don't think any code changes are needed here, but I will turn this into a documentation issue - it would be good to have an example of "filtering admin error emails" in our logging docs, as that's likely to be a common request (since it's the most visible use of logging by default in Django).