Guardar registros de solicitud de django en un archivo

Django shows the requests logs in command line, I want to save that logs in a file. I found a solución aquí but it saves the logs only that we print manually. Can we save all of the request and response logs in a separate file?

preguntado el 28 de mayo de 14 a las 12:05

2 Respuestas

To log the Django request debug events, check out my answer aquí sobre el uso del falla-muy bien-django config. You will also get 4xx and 5xx request events logged from Django's default loggers.

Note, though, that 2xx requests generally don't get logged by Django, if that's what you are after (only runserver shows them in the console). There is a workaround mentioned aquí, but you should generally use your server's access logs for these in production (e.g. acceso.log in nginx/Apache).

contestado el 23 de mayo de 17 a las 13:05

This should work on both linux and windows I hope:

python manage.py runserver > logs.txt

contestado el 28 de mayo de 14 a las 12:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.