in src/log4net/Core/LoggerManager.cs [61:122]
static LoggerManager()
{
try
{
// Register the AppDomain events, note we have to do this with a
// method call rather than directly here because the AppDomain
// makes a LinkDemand which throws the exception during the JIT phase.
RegisterAppDomainEvents();
}
catch (System.Security.SecurityException)
{
LogLog.Debug(_declaringType, "Security Exception (ControlAppDomain LinkDemand) while trying " +
"to register Shutdown handler with the AppDomain. LoggerManager.Shutdown() " +
"will not be called automatically when the AppDomain exits. It must be called " +
"programmatically.");
}
// Dump out our assembly version into the log if debug is enabled
LogLog.Debug(_declaringType, GetVersionInfo());
// Set the default repository selector
// Look for the RepositorySelector type specified in the AppSettings 'log4net.RepositorySelector'
string? appRepositorySelectorTypeName = SystemInfo.GetAppSetting("log4net.RepositorySelector");
if (!string.IsNullOrEmpty(appRepositorySelectorTypeName))
{
// Resolve the config string into a Type
Type? appRepositorySelectorType = null;
try
{
appRepositorySelectorType = SystemInfo.GetTypeFromString(appRepositorySelectorTypeName!, false, true);
}
catch (Exception e) when (!e.IsFatal())
{
LogLog.Error(_declaringType, $"Exception while resolving RepositorySelector Type [{appRepositorySelectorTypeName}]", e);
}
if (appRepositorySelectorType is not null)
{
// Create an instance of the RepositorySelectorType
object? appRepositorySelectorObj = null;
try
{
appRepositorySelectorObj = Activator.CreateInstance(appRepositorySelectorType);
}
catch (Exception e) when (!e.IsFatal())
{
LogLog.Error(_declaringType, $"Exception while creating RepositorySelector [{appRepositorySelectorType.FullName}]", e);
}
if (appRepositorySelectorObj is IRepositorySelector sel)
{
RepositorySelector = sel;
}
else
{
LogLog.Error(_declaringType, $"RepositorySelector Type [{appRepositorySelectorType.FullName}] is not an IRepositorySelector");
}
}
}
// Create the DefaultRepositorySelector if not configured above
RepositorySelector ??= new DefaultRepositorySelector(typeof(Repository.Hierarchy.Hierarchy));
}