On Wed, Sep 29, 2010 at 9:40 AM, Nick Phillips
<[email protected]> wrote:
> On Wed, 2010-09-29 at 09:00 +0800, Russell Keith-Magee wrote:
>
>> These all strike me as messages appropriate for a warning -- they're
>> all slightly concerning indications that you're either under some sort
>> of attack, or at the very least that your users are having a bad
>> experience on your site.
>>
>> This includes 404 -- manually entered URLs and annoying PHP hackbots
>> notwithstanding, your site shouldn't be generating 404s. If it is, you
>> should be investigating. The only argument I can see for 404 as an
>> INFO message is the prevalence; given that a 404 is often generated
>> without being a concern, it makes sense to make them easy to filter
>> out. However, IMHO, unilaterally ignoring 404s would be just as bad as
>> having too many. On top of that, any halfway decent log analysis tool
>> can filter these messages on a per-status code or per-URL basis.
>
> FWIW I agree with everything you say up to this point - it's just the
> conclusion that I differ on; I'd prefer to have the ability to use the
> logging config to send the 404s somewhere else. Not to ignore them, just
> to be able to deal with them separately as simply as possible. Since
> their issue is buried within the framework and can't easily be
> overridden, I think their ubiquity does justify the the lower priority.
I think I may be able to keep everyone happy here. With a couple of
modifications, this is something that can be handled as a logging
filter. All we need to do is pass in the status code as part of the
extra data that is part of the log message; then you could write a
filter to transform the log however you wanted -- for example:
class Info404Filter(logging.Filter):
def filter(self, record):
if record.status_code == 404:
record.levelno = logging.INFO
record.levelname = logging.getLevelName(logging.INFO)
return True
would, if installed, convert all 404 messages into INFO level.
Yours,
Russ Magee %-)
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.