问题
I'm using log4net in my application, it works fine every where.
I've used it in body of my WCF methods to log interactions between client and service. when ever a WCF client calls any of the methods, an exception occurs internally inside log4net saying that is can not retrieve stack information;
This is my wcf:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class MyWcfService : IMyWcfService
{
private static readonly ILog logger = LogManager.GetLogger(typeof(MyWcfService));
private static readonly object lockObject = new object();
...
...
...//other code are remove for simplicity
public void Disconnect()
{
logger.DebugFormat(WcfMessages.MethodCalled, "Disconnect");
lock (lockObject)
{
try
{
{
client = null;
logger.Info(string.Format(WcfMessages.ClientDisconnected));
}
}
catch (Exception exception)
{
logger.Error(string.Format(WcfMessages.ClientDisconnectException), exception);
}
}
}
}
Here is log4net's console appender output:
Log4Net Cofnig:
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger %method %-4line - %message%newline" />
</layout>
</appender>
why i see the exception? how i can solve it? Thanks.
来源:https://stackoverflow.com/questions/21088571/log4net-issue-inside-wcf