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.
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