CRP08
CRP08

Reputation: 151

How to do a request/session based logging in python?

I have a web service in which we want to add logs with SessionId/RequestId attached to it. Tried adding sessionId as part of Filter but when the concurrent requests comes to web service it overwrites the sessionId with new sessionId for all the logs, even for previous request which is running.

Upvotes: 0

Views: 729

Answers (1)

Vinay Sajip
Vinay Sajip

Reputation: 99365

You'll need to make sure your session information (or a key to it) is held in a thread local. I wrote a blog post about a similar issue (in that case it was about two different web applications on the same server, but the same principle applies in this case - making sure the contexts of multiple requests are kept isolated from each other). There's too much detail to reproduce here, so refer to the details in the linked post.

Upvotes: 1

Related Questions