Log4net 什么是LoggingEventData?如何使用,在哪里使用?

Log4net 什么是LoggingEventData?如何使用,在哪里使用?,log4net,Log4net,我想知道LoggingEvent和LoggingEventData之间的区别,为什么使用LoggingEventData,因为LoggingEventData只是LoggingEvent的一个可移植版本 我正在编写自己的自定义布局,在此布局中,只有在我调用GetLoggingEventData()之后,LoggingEvent的成员才对我可用,如果不调用此函数,我将获得所有LoggingEvent属性的空值。你能告诉我为什么会这样吗 class MyLayout:LayoutSkeleton

我想知道LoggingEvent和LoggingEventData之间的区别,为什么使用LoggingEventData,因为LoggingEventData只是LoggingEvent的一个可移植版本

我正在编写自己的自定义布局,在此布局中,只有在我调用GetLoggingEventData()之后,LoggingEvent的成员才对我可用,如果不调用此函数,我将获得所有LoggingEvent属性的空值。你能告诉我为什么会这样吗

 class MyLayout:LayoutSkeleton
 {
   public override void Format (TextWriter writer, LoggingEvent loggingEvent )
   {
     var initObj = new InitObj(loggingEvent);
   }
 }


Class InitObj {
     public InitObj(LoggingEveng loggingEvent) {
          String xyz = loggingEvent.Properties["xyz"]; 

           // This is null , when

           // There is no call to

           //loggingEvent.GetLoggingEventData();     
     }
}
我在LoggingEvent中查看了GetLoggingEventData函数:

public LoggingEventData GetLoggingEventData()
{
  return this.GetLoggingEventData(FixFlags.Partial);
}
FixFlags可能正在修复/启用loggingevent属性。
我对此不是很确定。

正如该项目的文档所述:

提供此构造函数是为了允许创建LoggingEvent 独立于log4net框架。如果您愿意,这将非常有用 需要自定义序列化方案


在此

中有一个用法示例,非常感谢您的帮助。很抱歉打扰您,我正在编写自己的自定义布局,在此布局中,只有在我调用GetLoggingEventData()之后,LoggingEvent的成员才可供我使用,如果不调用此函数,我将为所有LoggingEvent属性获取空值。你能告诉我为什么会这样吗?