Click here to Skip to main content
12,957,007 members (54,530 online)
Rate this:
Please Sign up or sign in to vote.
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.

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 22:54pm
rk_prabakar 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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,924
CHill60 3,550
Maciej Los 3,312
ppolymorphe 2,120
Jochen Arndt 1,973

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 26 Jul 2013
Copyright © CodeProject, 1999-2017
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