in src/log4net/Core/DefaultRepositorySelector.cs [261:342]
public ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType, string repositoryName, bool readAssemblyAttributes)
{
if (repositoryAssembly == null)
{
throw new ArgumentNullException("repositoryAssembly");
}
// If the type is not set then use the default type
if (repositoryType == null)
{
repositoryType = m_defaultRepositoryType;
}
lock(this)
{
// Lookup in map
ILoggerRepository rep = m_assembly2repositoryMap[repositoryAssembly] as ILoggerRepository;
if (rep == null)
{
// Not found, therefore create
LogLog.Debug(declaringType, "Creating repository for assembly [" + repositoryAssembly + "]");
// Must specify defaults
string actualRepositoryName = repositoryName;
Type actualRepositoryType = repositoryType;
if (readAssemblyAttributes)
{
// Get the repository and type from the assembly attributes
GetInfoForAssembly(repositoryAssembly, ref actualRepositoryName, ref actualRepositoryType);
}
LogLog.Debug(declaringType, "Assembly [" + repositoryAssembly + "] using repository [" + actualRepositoryName + "] and repository type [" + actualRepositoryType + "]");
// Lookup the repository in the map (as this may already be defined)
rep = m_name2repositoryMap[actualRepositoryName] as ILoggerRepository;
if (rep == null)
{
// Create the repository
rep = CreateRepository(actualRepositoryName, actualRepositoryType);
if (readAssemblyAttributes)
{
try
{
// Look for aliasing attributes
LoadAliases(repositoryAssembly, rep);
// Look for plugins defined on the assembly
LoadPlugins(repositoryAssembly, rep);
// Configure the repository using the assembly attributes
ConfigureRepository(repositoryAssembly, rep);
}
catch (Exception ex)
{
LogLog.Error(declaringType, "Failed to configure repository [" + actualRepositoryName + "] from assembly attributes.", ex);
}
}
}
else
{
LogLog.Debug(declaringType, "repository [" + actualRepositoryName + "] already exists, using repository type [" + rep.GetType().FullName + "]");
if (readAssemblyAttributes)
{
try
{
// Look for plugins defined on the assembly
LoadPlugins(repositoryAssembly, rep);
}
catch (Exception ex)
{
LogLog.Error(declaringType, "Failed to configure repository [" + actualRepositoryName + "] from assembly attributes.", ex);
}
}
}
m_assembly2repositoryMap[repositoryAssembly] = rep;
}
return rep;
}
}