Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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.

C#
<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?

C#
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"
Posted
Comments
♥…ЯҠ…♥ 26-Jul-13 9:08am    
Currently am using log4net in my service, could you write an article so that I can follow it on my application.
TapasU 28-Jul-13 1:57am    
Hey.. you can use this link on how to use Log4net. This is my article on using Log4Net with Isolated storage.
http://www.codeproject.com/Tips/604115/Isolated-Storage-using-Log4Net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900