D
D
Dmitry Grebenshchikov2015-06-08 12:05:52
Django
Dmitry Grebenshchikov, 2015-06-08 12:05:52

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

4 answer(s)
M
marazmiki, 2015-06-08
@marazmiki

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.

S
Sergey Vilgelm, 2015-06-08
@svilgelm

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.

S
Stanislav Fateev, 2015-06-08
@svfat

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/

V
Vladislav Sklyar, 2015-06-08
@VladSkliar

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 question

Ask a Question

731 491 924 answers to any question