如何检查是否有调用log4net的XmlConfigurator.Configure
成功了吗?如果无法正确加载日志记录配置(即文件不存在、文件格式不正确等),我想进行 Web 服务调用
最佳答案
来自 the FAQ :
To prevent silent failure of log4net as reported as LOG4NET-342, log4net supports a way to evaluate if it was configured and also to evaluate messages generated on startup since 1.2.11. To check if log4net was started and configured properly one can check the property
log4net.Repository.ILoggerRepository.Configured
and enumerate the configuration messages as follows:if(!log4net.LogManager.GetRepository().Configured) { // log4net not configured foreach(log4net.Util.LogLog message in log4net.LogManager.GetRepository().ConfigurationMessages.Cast<log4net.Util.LogLog>()) { // evaluate configuration message } }
关于.net - 检查 log4net XmlConfigurator 是否成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28723920/