Log4net Issue inside wcf

女生的网名这么多〃 提交于 2020-01-17 03:02:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!