Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET WCF Web-Development , +
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"
Posted 25-Jul-13 23:54pm
TapasU729
Comments
rk_prabakar at 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 at 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)



Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 26 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100