XmlConfiguratorAttribute不使用此.Log和log4net?

XmlConfiguratorAttribute不使用此.Log和log4net?,log4net,Log4net,我正在使用此.Log并尝试让应用程序开始使用以下属性: [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)] 但这似乎不起作用,当我打开log4net调试时,我似乎无法找到原因。我查看了this.Log代码,在Log4NetLog.cs文件中找到了以下行: [assembly: XmlConfigurator(Watch = true)] 这会覆盖我自己的程序集设置吗?有

我正在使用此.Log并尝试让应用程序开始使用以下属性:

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
但这似乎不起作用,当我打开log4net调试时,我似乎无法找到原因。我查看了this.Log代码,在Log4NetLog.cs文件中找到了以下行:

[assembly: XmlConfigurator(Watch = true)]

这会覆盖我自己的程序集设置吗?有什么方法可以让它工作吗?

因为您有了源代码,所以可以删除该行并重新编译

或者,您可以在运行时覆盖设置,例如添加行(在程序的开头或静态构造函数中)


在提出问题时,您是否意识到XmlConfiguratorAttribute的限制?如果在包含该属性的程序集中未首次使用LoggerManager,则可能不会考虑该属性。因此,我非常赞成斯格摩尔提出的替代方案。真正地这是非常有用的信息。谢谢
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("Log4net.config"));