查看log4net XmlConfigurator是否成功
Check whether log4net XmlConfigurator succeeded
如何检查对 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
}
}
如何检查对 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 } }