Answer the question
In order to leave comments, you need to log in
How to log request in Django?
Good afternoon!
I would like to receive data about the user when an error occurs! At least the user ID (request.user.id) and what requests he sent!
How can this be implemented?
Answer the question
In order to leave comments, you need to log in
Use sentry (you can use both a cloud SaaS platform and raise a copy at your own facilities: the product is free and open source). It's all there out of the box.
https://docs.djangoproject.com/en/1.8/topics/logging/
You need to enable logging for django.request
Or you can write your own Handler, but it's not so easy to forward a request to it, you need to write a filter, constantly returning true, but somehow registering the request, sorry, I don’t remember, it was a long time ago.
In the ADMINS variable in settings.py, you can add e-mails of those who will receive error messages when DEBUG = False
https://docs.djangoproject.com/en/1.8/ref/settings/
It is possible to try through Middleware.
https://docs.djangoproject.com/en/1.8/topics/http/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question