Hi All,
I am working on a web service to WCF migration project. In my old web service, I have few logger statements like below.
<pre lang="cs">
using (log4net.ThreadContext.Stacks["ClientIP"].Push(Context.Request.ServerVariables["REMOTE_ADDR"]))
{
using (log4net.ThreadContext.Stacks["UserName"].Push(strUserName))
{
log.Info("Log Me Please");
}
}
The service will be deployed on one of the server and we will have multiple clients access the service simultaneously.
Goal to achieve: I want to have user specific log statements in a
single log file, which I am also getting in my current web service. However, I want to achieve the same functionality (user details specific logs) in the WCF service.
Concerns:
1. Is it necessary to use ThreadContext and Push values in Stacks for multithreaded operations?
2. What if I use only only log statements without pushing the values in Stack (See below)? Will this serve my purpose too?
log.Info("Log Me Please");
I read many posts related to this but I am little confused when it comes to implementation.
Thanks in advance.
"Happy Coding"