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.
get_response(request) # Code to be executed for each request/response after # the view is called. return response. The get_response callable provided by Django might be the actual view (if this is the last listed middleware) or it might be the next middleware in the chain.
In Django, middleware is a lightweight plugin that processes during request and response execution. Middleware is used to perform a function in the application. The functions can be a security, session, csrf protection, authentication etc.
Custom middleware in Django is created either as a function style that takes a get_response callable or a class-based style whose call method is used to process requests and responses. It is created inside a file middleware.py . A middleware is activated by adding it to the MIDDLEWARE list in Django settings.
Middleware and decorators are similar and can do the same job. They provide a means of inserting intermediary effects either before or after other effects downstream in the chain/stack.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With