Code

Opened 3 years ago

Closed 20 months ago

Last modified 20 months ago

#17069 closed New feature (fixed)

Extend the error logger's API to allow ignoring some errors

Reported by: julien Owned by: peppergrower
Component: Documentation Version: master
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.

Attachments (0)

Change History (6)

comment:1 Changed 3 years ago by carljm

  • Component changed from Core (Other) to Documentation
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.3 to SVN

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 Changed 2 years ago by dlowe

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 Changed 20 months ago by peppergrower

  • 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 Changed 20 months ago by Michael Johnson <mjjohnson.geo@…>

  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 20 months ago by Tim Graham <timograham@…>

In [e06189f7ceb48013b37b902588bea6750c989b14]:

Merge pull request #297 from mjjohnson/ticket_17069

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

comment:6 Changed 20 months ago by Tim Graham <timograham@…>

In [4b8c6c405619f7624847a469304e0d1cea053f19]:

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

Backport of e06189f7ceb48013b37b902588bea6750c989b14 from master.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.