c# – Log4Net何时配置?

前端之家收集整理的这篇文章主要介绍了c# – Log4Net何时配置?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
鉴于你有
[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.

原文链接:https://www.f2er.com/csharp/243522.html

猜你在找的C#相关文章