Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
Django Logging and Session Information

I have tried to google this one to death but could not find the answer, so if someone can point me to the doc or explain how to do this that would be great.

I am trying to include Session information from the Django request (i.e cookies) in all logs, now this is fine in the views etc that have access to the request I can just format that in the message that I am logging.

The issue is with installed packages, these have no knowledge of the session and log without this information and I am yet to find a way to define this in the formatter so that the formatter is more session aware.

I need to do this as I have to send all logs to a syslog server and would like to be able to search the logs for an entire session and get even package level logs.

EDIT:

Sorry guys I am editing the question for a little more clarity.

The overall goal is to wrap all messages that get generated in a api call with the session information this would include any packages that are not directly tied to the Django application itself, this is so that I can search for all logs relating to a session. I hope this makes sense

Thanks

John.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Something like this:

from django.contrib.sessions.backends.db import SessionStore

s = SessionStore()
# stored as seconds since epoch since datetimes are not serializable in JSON.
s['last_login'] = 1376587691
>>> s.create()
>>> s.session_key
'2b1189a188b44ad18c35e113ac6ceead'

Django docs ref: https://docs.djangoproject.com/en/1.10/topics/http/sessions/#using-sessions-out-of-views

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda