title: Log4Net with ASP.NET Core 2.2 to write to a File
body: <p>In my ASP.NET Core 2.2 application I installed <a href="https://github.com/huorswords/Microsoft.Extensions.Logging.Log4Net.AspNetCore" rel="nofollow noreferrer">Microsoft.Extensions.Logging.Log4Net.AspNetCore</a> </p>
  
  <p>in startup.cs</p>
  
  <pre><code>public class Startup
      {
          private readonly ILogger _logger;
          public Startup(IConfiguration configuration, ILogger&lt;Startup&gt; logger)
          {
              Configuration = configuration;
              _logger = logger;
          }
   public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
      ....
      .....
        _logger.LogInformation("Added TodoRepository to services");
      .....
      .....
          }
  
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                  UserManager&lt;User&gt; userManager, RoleManager&lt;Role&gt; roleManager,
                  ILoggerFactory loggerFactory)
      {
       ....
       loggerFactory.AddLog4Net();
       ....
  
      }
  </code></pre>
  
  <p>In my Home controller</p>
  
  <pre><code> public IActionResult Index()
          {
              _logger.LogInformation("Home Index page");
              _logger.LogWarning("Home Index page");
              _logger.LogError("Home Index page");
              _logger.LogDebug("Home Index page");
              return View();
          }
  </code></pre>
  
  <p>I see the logs showing up in Visual Studio Output window, but this is not writing to any files.</p>
  
  <p>log4net.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;log4net&gt;
    &lt;appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
      &lt;lockingModel type="log4net.Appender.FileAppender+MinimalLock"/&gt;
      &lt;file value="C:\Temp\WebAppFolder" /&gt;
      &lt;datePattern value="yyyy-MM-dd.'txt'"/&gt;
      &lt;staticLogFileName value="false"/&gt;
      &lt;appendToFile value="true"/&gt;
      &lt;rollingStyle value="Date"/&gt;
      &lt;maxSizeRollBackups value="100"/&gt;
      &lt;maximumFileSize value="15MB"/&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%date [%thread] %-5level App  %newline %message %newline %newline"/&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;
    &lt;root&gt;
      &lt;level value="ALL"/&gt;
      &lt;appender-ref ref="RollingLogFileAppender"/&gt;
    &lt;/root&gt;
  &lt;/log4net&gt;
  </code></pre>