private static void InternalConfigure()

in src/log4net/Config/XmlConfigurator.cs [77:120]


  private static void InternalConfigure(ILoggerRepository repository, Func<XmlElement?> getConfigSection)
  {
    LogLog.Debug(_declaringType, $"configuring repository [{repository.Name}] using .config file section");

    try
    {
      LogLog.Debug(_declaringType, $"Application config file is [{SystemInfo.ConfigurationFileLocation}]");
    }
    catch (Exception e) when (!e.IsFatal())
    {
      // ignore error
      LogLog.Debug(_declaringType, "Application config file location unknown");
    }

    try
    {
      if (getConfigSection() is not XmlElement configElement)
      {
        // Failed to load the xml config using configuration settings handler
        LogLog.Error(_declaringType, @$"Failed to find configuration section 'log4net' in the .config file '{SystemInfo.ConfigurationFileLocation}'.
Check your .config file for the <log4net> and <configSections> elements.
The configuration section should look like: <section name=""log4net"" type=""log4net.Config.Log4NetConfigurationSectionHandler,log4net"" />");
      }
      else
      {
        // Configure using the xml loaded from the config file
        InternalConfigureFromXml(repository, configElement);
      }
    }
    catch (System.Configuration.ConfigurationException confEx)
    {
      if (confEx.BareMessage.IndexOf("Unrecognized element", StringComparison.Ordinal) >= 0)
      {
        // Looks like the XML file is not valid
        LogLog.Error(_declaringType, "Failed to parse config file. Check your .config file is well formed XML.", confEx);
      }
      else
      {
        // This exception is typically due to the assembly name not being correctly specified in the section type.
        string configSectionStr = "<section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler," + Assembly.GetExecutingAssembly().FullName + "\" />";
        LogLog.Error(_declaringType, "Failed to parse config file. Is the <configSections> specified as: " + configSectionStr, confEx);
      }
    }
  }