title: Deploy as single-file in .net5 with log4net throws exception for config-file
body: <p>Trying to deploy a console-application written in .Net 5 with log4net as a single-file.
  Running deployed application throws exception.</p>
  <p>Steps to reproduce</p>
  <ul>
  <li>dotnet new console --name TestConsole --language C# (make sure .net 5.0)</li>
  <li>Install-Package log4net</li>
  <li>Program.cs</li>
  </ul>
  <pre><code>static void Main(string[] args)
  {
  log4net.Config.XmlConfigurator.Configure(new FileInfo(&quot;log.config&quot;));
  var logger = log4net.LogManager.GetLogger(&quot;TestLogger&quot;);
  logger.Info(&quot;Hello World!&quot;);
  }
  </code></pre>
  <ul>
  <li>log.config (copy always)</li>
  </ul>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
  &lt;log4net&gt;
    &lt;logger name=&quot;TestLogger&quot;&gt;
      &lt;level value=&quot;ALL&quot; /&gt;
      &lt;appender-ref ref=&quot;console&quot; /&gt;
    &lt;/logger&gt;
    &lt;appender name=&quot;console&quot; type=&quot;log4net.Appender.ConsoleAppender&quot;&gt;
      &lt;layout type=&quot;log4net.Layout.PatternLayout&quot;&gt;
        &lt;conversionPattern value=&quot;%level - %message%newline&quot; /&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;
  &lt;/log4net&gt;
  </code></pre>
  <ul>
  <li>publish (no single file) = works (when running the console application)</li>
  </ul>
  <p>dotnet publish -o .\Publish --self-contained true -r win-x64</p>
  <ul>
  <li>publish (no single file) = throws exception (when running the console application)</li>
  </ul>
  <p>dotnet publish -o .\Publish --self-contained true -r win-x64 -p:PublishSingleFile=true</p>
  <p>excpetion thrown:</p>
  <pre><code>log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
  System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
   ---&gt; System.IO.FileNotFoundException: Cannot find file. (0x80070002)
     at System.Reflection.RuntimeModule.GetFullyQualifiedName()
     at System.Reflection.RuntimeModule.get_Name()
     at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
     at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
     at System.Configuration.ClientConfigurationHost.get_ConfigPaths()
     at System.Configuration.ClientConfigurationHost.GetStreamName(String configPath)
     at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp()
     at System.Configuration.Internal.DelegatingConfigHost.get_IsAppConfigHttp()
     at System.Configuration.ClientConfigurationSystem..ctor()
     at System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
     --- End of inner exception stack trace ---
     at System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
     at System.Configuration.ConfigurationManager.PrepareConfigSystem()
     at System.Configuration.ConfigurationManager.GetSection(String sectionName)
     at System.Configuration.ConfigurationManager.get_AppSettings()
     at log4net.Util.SystemInfo.GetAppSetting(String key)
  log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
  System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
   ---&gt; System.IO.FileNotFoundException: Cannot find file. (0x80070002)
     at System.Reflection.RuntimeModule.GetFullyQualifiedName()
     at System.Reflection.RuntimeModule.get_Name()
     at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
     at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
     at System.Configuration.ClientConfigurationHost.get_ConfigPaths()
     at System.Configuration.ClientConfigurationHost.GetStreamName(String configPath)
     at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp()
     at System.Configuration.Internal.DelegatingConfigHost.get_IsAppConfigHttp()
     at System.Configuration.ClientConfigurationSystem..ctor()
     at System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
     --- End of inner exception stack trace ---
     at System.Configuration.ConfigurationManager.PrepareConfigSystem()
     at System.Configuration.ConfigurationManager.GetSection(String sectionName)
     at System.Configuration.ConfigurationManager.get_AppSettings()
     at log4net.Util.SystemInfo.GetAppSetting(String key)
  </code></pre>
  <p>What have I missed?</p>