10

I want to log every request that ever comes through my sever. Is there a plugin/middleware for this?

Ideally I'd like it to be queryable.

2

3 Answers 3

4

Don't know if that's what you want, but django-sentry is a great app for logging errors that occur in your Django site. They can be shown in a (well-designed!) web interface, allowing for sorting like number of occurrences of an error etc.

If you just want to log requests, Apache's access.log should be enough. And I guess there are many tools for parsing and displaying the content of Apache logs.

3

You best bet seems to be django-request.

2

You should keep the logging inside of your webserver, not in Django. Although it can log, it's not something you generally would want to do.

If you really want to though, here's an example middleware:

class RequestLoggingMiddleware(object):
    def process_request(self, request):
        syslog.syslog(' '.join([
            request.META['remote_addr'],
            request.get_full_path(),
        ]))

Not the answer you're looking for? Browse other questions tagged or ask your own question.