Is there a Django middleware/plugin that logs all my requests in a organized fashion? [closed]
开发者_如何学编程
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionI 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.
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.
You best bet seems to be django-request.
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(),
]))
精彩评论