in src/log4net/Config/XmlConfigurator.cs [517:574]
private static void InternalConfigure(ILoggerRepository repository, FileInfo configFile)
{
LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using file [" + configFile + "]");
if (configFile == null)
{
LogLog.Error(declaringType, "Configure called with null 'configFile' parameter");
}
else
{
// Have to use File.Exists() rather than configFile.Exists()
// because configFile.Exists() caches the value, not what we want.
if (File.Exists(configFile.FullName))
{
// Open the file for reading
FileStream fs = null;
// Try hard to open the file
for(int retry = 5; --retry >= 0; )
{
try
{
fs = configFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
break;
}
catch(IOException ex)
{
if (retry == 0)
{
LogLog.Error(declaringType, "Failed to open XML config file [" + configFile.Name + "]", ex);
// The stream cannot be valid
fs = null;
}
System.Threading.Thread.Sleep(250);
}
}
if (fs != null)
{
try
{
// Load the configuration from the stream
InternalConfigure(repository, fs);
}
finally
{
// Force the file closed whatever happens
fs.Dispose();
}
}
}
else
{
LogLog.Debug(declaringType, "config file [" + configFile.FullName + "] not found. Configuration unchanged.");
}
}
}