我已经写好了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 "?"*/,
}
我做错了什么?
由于
答案 0 :(得分:1)
您可以尝试在自定义appender的构造函数中添加以下行:
Fix = FixFlags.All;
答案 1 :(得分:0)
在Append-Method中设置LoggingEvent的Fix属性:
protected override void Append(LoggingEvent loggingEvent)
{
loggingEvent.Fix = FixFlags.All;
var className = loggingEvent.LocationInformation.ClassName;
// ...
}