Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!