在log4net的Web服务 [英] Log4net in a web service

查看:185
本文介绍了在log4net的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本都为

log4net的,只有当XmlConfigurator.Configure()被调用作品

不过,我无法评论那里,我没有任何的声誉(刚刚签署了)。

However, I couldn't comment there as I don't have any reputation (just signed up).

感谢任何有益的意见。
如果我这里有什么问题,请指教。
非常感谢你。贝恩德

Thanks for any helpful comments. If I do anything wrong here, please advise. Thank you very much. Bernd

更新:
感谢建设性的提示。我已经取得了一些进展,因此将详细讲解:
我使用log4net的一个(VS生成的C#Web服务)之内。我得到的调试文件中的调试信息,但是在VS(2012年)我得到每一个日志调用的消息:

Update: Thanks for constructive hints. I've have made some progress and therefore will explain in more detail: I use log4net within a (VS generated C# web service). I do get the debug information in the debug file, however within VS (2012) I do get the message for every logging call:

log4net的:错误而retreiving堆栈帧信息内容时发生异常。
System.NullReferenceException:明镜Objektverweis wurde nicht奥夫EINE Objektinstanz festgelegt。
   贝log4net.Core.StackFrameItem..ctor(的StackFrame帧)

log4net:ERROR An exception ocurred while retreiving stack frame information. System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. bei log4net.Core.StackFrameItem..ctor(StackFrame frame)

要编码:

我通过一个XML的文件配置的:

I configured it via an xml-File:

<?xml version="1.0" encoding="utf-8" ?>
<log4net>  
  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
    <file value="Logs/debug.log" />
    <encoding value="utf-8" />
    <appendToFile value="true" />
    <maximumFileSize value="10MB" />
    <maxSizeRollBackups value="2" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level (%class#%method:%line):%message%newline" />
    </layout>
  </appender>
  <root>
    <level value="DEBUG" />    
    <appender-ref ref="RollingFile" />
  </root>
</log4net>

我的Web服务是这样的:

My web service looks like this:

public class ObjectInfo : IObjectInfo
{    
    private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);



    public void DoWork()        {
      Logging.LoggingUtil.InitializeLogging();
      log.Debug("Some message");
    }
}

希望这是相当足够。该LoggingUtil-类基本上是这样的:

Hope this is quite sufficient. The LoggingUtil- class basically looks like this:

private const String Log4NetConfigurationFilePath = "log4net-config.xml"; //real path looks somewhat different
public static void InitializeLogging()
{    
  XmlConfigurator.Configure(new FileInfo(Log4NetConfigurationFilePath));     
}

我不知道,如果问题是堆栈跟踪不能在卡西被发现微软不允许这样,以保护其执行Web服务的?

I wonder, if the problem is that the stack trace cannot be found out within Cassine as Microsoft doesn't allow this in order to protect their implementation of the web service?

推荐答案

由于这里,这说明当有呼叫链中的动态方法时发生错误。

As explained here, this error occurs when there is a dynamic method in the call chain.

有他们声称有固定的版本中这个错误> 1.12.2

There they claim to have this error fixed in versions > 1.12.2.

这篇关于在log4net的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆