What is the difference between log4net.ThreadContext and log4net.LogicalThreadContext?

前端 未结 1 1054
囚心锁ツ
囚心锁ツ 2020-12-05 07:05

UPDATED on 11/18/2014 - While browsing the log4net source repository, I found that the implementation of LogicalThreadContext was modified in November 2011 to that it stores

相关标签:
1条回答
  • 2020-12-05 07:30

    Warning: this is guesswork.

    Suppose you're writing a server, and serving a request means you have to talk to a bunch of different services. Being a thoroughly modern developer, you make these requests asynchronously, coordinating when everything's replied (or timed out) in order to respond to the original request.

    That means the work corresponding to a single request is scattered amongst many different threads (processing the web service responses asynchronously). I suspect that CallContext is used to propagate the "everything I'm doing is because of this one incoming request" to different threads, so that you can gather all the logs for that request together. ThreadContext wouldn't help there. Note that I'm assuming all the work is being performed in a single AppDomain, so your concern there wouldn't be a problem.

    0 讨论(0)
提交回复
热议问题