LocationInformation in LoggingEvent in CustomAppendar

左心房为你撑大大i 提交于 2019-12-23 20:06:57

问题


I have written custon Appendar and override Append method. I am getting LoggingEvent in that method but when I looked at LocationInformation it is empty it shows only "?" in following properties.

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 "?"*/,

}

What I am doing wrong ?

Thanks


回答1:


Could you try adding following line in the constructor of your custome appender:

Fix = FixFlags.All;



回答2:


Set the Fix Property on the LoggingEvent in the Append-Method:

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

     var className = loggingEvent.LocationInformation.ClassName;
     // ... 
}


来源:https://stackoverflow.com/questions/8903291/locationinformation-in-loggingevent-in-customappendar

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