Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#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 Carl Meyer, 12 years ago

Component: Core (Other)Documentation
Triage Stage: UnreviewedAccepted
Version: 1.3SVN

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).

comment:2 by J. David Lowe, 12 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 peppergrower, 12 years ago

Has patch: set
Owner: changed from nobody to peppergrower

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 Michael Johnson <mjjohnson.geo@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [32ffcb21a00e08eb478cc287bc3254ee765d815d]:

Fixed #17069 -- Added log filter example to docs.

Added an example of filtering admin error emails (to exclude
UnreadablePostErrors) to the docs.

comment:5 by Tim Graham <timograham@…>, 12 years ago

In [e06189f7ceb48013b37b902588bea6750c989b14]:

Merge pull request #297 from mjjohnson/ticket_17069

Fixed #17069 -- Added log filter example to docs.

comment:6 by Tim Graham <timograham@…>, 12 years ago

In [4b8c6c405619f7624847a469304e0d1cea053f19]:

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

Backport of e06189f7ceb48013b37b902588bea6750c989b14 from master.

Note: See TracTickets for help on using tickets.
Back to Top