Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda