鉴于你有
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config",Watch = true)]
在AssemblyInfo.cs文件中,何时配置Log4Net?它是在应用程序启动时还是第一次使用记录器时?
解决方法
当您调用LoggerManager类时,将使用配置文件.这通常是通过调用LogManager.GetLogger引起的.
有关详细信息,请参阅http://logging.apache.org/log4net/release/sdk/log4net.Config.XmlConfiguratorAttribute.html;特别注意:
Log4net will only look for assembly level configuration attributes once. When using the log4net assembly level attributes to control the configuration of log4net you must ensure that the first call to any of the LoggerManager methods is made from the assembly with the configuration attributes.