title: How can I log to Special Folders with log4net?
body: <p>How can I log to special folders (e.g. <code>%APPDATA%</code>) using the app.config file?</p>
  
  <p>I can do it programmatically, but I need to be able to use the app.config file for configuration. I have seen a post of using <code>%envFolderPath</code>.It is not available in the latest released version, but only in their latest code.</p>
  
  <p>Below is the code that I setting the log to special folders programmatically.</p>
  
  <pre><code>public void ExampleLog
  {
      XmlConfigurator.Configure();
  
      var fileName = GetFileName();
      var appender = new log4net.Appender.RollingFileAppender
      {
          Layout = new log4net.Layout.PatternLayout("%d - %m%n"),
          File = fileName,
          MaxSizeRollBackups = 10,
          MaximumFileSize = "100MB",
          AppendToFile = true,
          Threshold = Level.Debug
      };
  
      appender.ActivateOptions();
      BasicConfigurator.Configure(appender);
  }
  
  private static string GetFileName()
  {
      const string subPath = "MySubFolder";
      var path = String.Format(@"{0}\{1}", Environment.GetFolderPath  (Environment.SpecialFolder.CommonApplicationData), subPath);
      const string logName = "Log.txt";
      return Path.Combine(path, logName);
  }
  </code></pre>