Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WCF service with 3 Operations OP1, OP2 & OP3. I'm trying to write 3 different log files(OP1.Log, OP2.Log, OP3.Log) based on the operation called using Log4net.

What I have tried:

<pre><!--<appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file type="log4net.Util.PatternString" value="C:\%property{logName}.log" />


In code I set the
log4net.GlobalContext.Properties["logName"] = operationName; //"OP1 or OP2 
                                         or OP3 based on the operation gets called
            log4net.Config.XmlConfigurator.Configure();
            ILog log = LogManager.GetLogger(typeof(operationName));

When I submit 2 requests OP1(first) & OP2(second) both Log entries goes in to OP1.Log
When I reverse the order
OP2(first) & OP1(second
both Log entries goes in to OP2.Log

I tried using the ThreadContext and no luck. I checked lot of links that has same issue but nothing worked. Appreciated any experts help.
Posted

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