3

我已经编写了 custon Appendar 并覆盖了 Append 方法。我在该方法中获取 LoggingEvent,但是当我查看 LocationInformation 时它是空的,它只显示“?” 在以下属性中。

protected override void Append(log4net.Core.LoggingEvent loggingEvent)
{

ClassName = loggingEvent.LocationInformation.ClassName /*contains "?"*/,
MethodName = loggingEvent.LocationInformation.MethodName /*contains "?"*/,
FileName = loggingEvent.LocationInformation.FileName /*contains "?"*/,
FullInfo = loggingEvent.LocationInformation.FullInfo /*contains "?"*/,

}

我做错了什么?

谢谢

4

2 回答 2

1

您能否尝试在您的客户附加程序的构造函数中添加以下行:

Fix = FixFlags.All;
于 2012-01-21T16:00:18.083 回答
0

在 Append-Method 中设置 LoggingEvent 的 Fix 属性:

protected override void Append(LoggingEvent loggingEvent)
{
     loggingEvent.Fix = FixFlags.All;

     var className = loggingEvent.LocationInformation.ClassName;
     // ... 
}
于 2015-06-23T09:27:05.680 回答