title: Log4Net doesn’t write log in release mode - Console Application
body: <p>I have a console application and have a class library which wraps the Log4Net methods. Now when run the application in debug mode it writes log but when it is built in release mode it doesn’t write log file. What would be the solution for this? The sample code and config file is given below</p>
  
  <p>My development environment is </p>
  
  <ul>
  <li>Visual Studio 2013 and .NET Framework 4.5</li>
  </ul>
  
  <p><strong>Console Application</strong></p>
  
  <pre><code>namespace ConsoleApplication1
  {
      class Program
      {
          static void Main(string[] args)
          {
              log4net.GlobalContext.Properties["LogFileName"] = "TestLogin.txt";
              Logger log = new Logger(typeof(Program));
              log.Info("Logging is enabled!!");
          }
      }
  }
  </code></pre>
  
  <p><strong>App.config in Console Application</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/&gt;
    &lt;/configSections&gt;
      &lt;startup&gt; 
          &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
      &lt;/startup&gt;
      &lt;log4net&gt;
        &lt;appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
          &lt;file type="log4net.Util.PatternString" value ="%property{LogFileName}"/&gt; 
          &lt;layout type="log4net.Layout.PatternLayout"&gt;
            &lt;conversionPattern value="%date [%thread] %level  - %message%newline%exception" /&gt;
          &lt;/layout&gt;
        &lt;/appender&gt;
        &lt;root&gt;
          &lt;level value="ALL" /&gt;
          &lt;appender-ref ref="RollingFileAppender" /&gt;
        &lt;/root&gt;
      &lt;/log4net&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>Class Library</strong></p>
  
  <pre><code>using log4net;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  [assembly: log4net.Config.XmlConfigurator(Watch = true)]
  namespace Logging
  {
      public class Logger
      {
          private readonly ILog log = null;
  
          public Logger(Type type)
          {
              log = LogManager.GetLogger(type);
          }
          public void Info(object message)
          {
              log.Info(message);
          }
      }
  }
  </code></pre>
  
  <p>I have followed the post and it didn’t help me to figure out why Log4Net doesn’t write in log file in release mode?</p>
  
  <p><a href="https://stackoverflow.com/questions/4045203/log4net-doesnt-log-when-running-a-net-4-0-windows-application-built-in-release">log4net doesn&#39;t log when running a .Net 4.0 Windows application built in Release mode</a></p>