title: Configure log4net AdoNetAppender in asp.net core application
body: <p>I am trying to configure log4net using MicroKnights AdoNetAppender(nuget 3rd party library) for my asp.net core application. However nothing is getting logged in database. Also I am not getting any errors when running the application. I suspect the connectionType is causing the trouble.</p>
  
  <p>log4net configuration file :</p>
  
  <pre><code>    &lt;log4net&gt;
    &lt;appender name="AdoNetAppender" type="MicroKnights.Logging.AdoNetAppender, MicroKnights.Log4NetAdoNetAppender"&gt;
      &lt;bufferSize value="1" /&gt;
      &lt;connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=4.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
      &lt;connectionStringName value="log4net" /&gt;
      &lt;connectionStringFile value="appsettings.json" /&gt;
      &lt;commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" /&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@log_date" /&gt;
        &lt;dbType value="DateTime" /&gt;
        &lt;layout type="log4net.Layout.RawTimeStampLayout" /&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@thread" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="255" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%thread" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@log_level" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="50" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%level" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@logger" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="255" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%logger" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@message" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="4000" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%message" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@exception" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="2000" /&gt;
        &lt;layout type="log4net.Layout.ExceptionLayout" /&gt;
      &lt;/parameter&gt;
    &lt;/appender&gt;
    &lt;root&gt;
      &lt;level value="ALL" /&gt;
      &lt;appender-ref ref="AdoNetAppender" /&gt;
    &lt;/root&gt;
  &lt;/log4net&gt;
  </code></pre>
  
  <p>appsettings.json:</p>
  
  <pre><code>{
    "Logging": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "AllowedHosts": "*",
    "connectionStrings": {
      "log4net": "Server=[[ServerName]]; Database=[[DatabaseName]]; Trusted_Connection=True; MultipleActiveResultSets=true"
    }
  }
  </code></pre>
  
  <p>Main method in program.cs</p>
  
  <pre><code> public static void Main(string[] args)
          {
              var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
              XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
  
              ILog log = log4net.LogManager.GetLogger("Logger");
  
              log.Info("logging to database");
  
              CreateWebHostBuilder(args).Build().Run();
          }
  </code></pre>
  
  <p>Any help would be appreciated.</p>