title: What happens if Log4Net doesn't have permission to access the file system
body: <p>I'm implementing a logging solution with Log4Net for a Windows NT Service. I can flip a switch in a configuration file to start logging information to the file system. So far I've been able to accomplish this by having a rolling file appender and having log4net "Watch" the configuration file.</p>
  
  <p>What I've notice is that Log4Net will create empty log files as soon as the service starts, even if all logging is turned off and I don't intend to log.</p>
  
  <p>I can't find much information on this topic other than this post:</p>
  
  <p><a href="https://stackoverflow.com/questions/2533403/log4net-how-to-disable-creation-of-empty-log-file-on-app-start">How to disable creation of empty log file on app start?</a></p>
  
  <p>My concern is that someone could set up the service with a very low level set of permissions that wouldn't even have access to create the log files on the file system. I don't want to incur the performance penalty of having exceptions thrown every time I hit a logging statement even if I didn't intend to log.</p>
  
  <p>I've wrapped each logging statement with check to see if the logging level is enabled before attempting to log, but I'm still not sure if in the inner workings of log4net whether or not exceptions are going to still be thrown if the file configured in the appender wasn't created.</p>
  
  <pre><code>if (logger.IsDebugEnabled)
  {
      logger.DebugFormat(format, traceMessage);    
  }
  </code></pre>
  
  <p>Does anyone know what log4net will do if it can't create the log files initially?</p>
  
  <p>Here is a little information about my configuration. Logging works fine when it is turned on, I'm just worried about permissions issues.</p>
  
  <p>Attribute on my logging class to watch for config changes:</p>
  
  <p><code>
  [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Logging.config", Watch = true)]
  </code></p>
  
  <p>Appender:</p>
  
  <pre><code>  &lt;appender name="Test" type="log4net.Appender.RollingFileAppender"&gt;
      &lt;file type="log4net.Util.PatternString" value=".\\AppLogs\\_test.%appdomain.log" /&gt;
      &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
        &lt;levelMin value="ALL" /&gt;
        &lt;levelMax value="FATAL" /&gt;
        &lt;acceptOnMatch value="false"/&gt;
      &lt;/filter&gt;
      &lt;filter type="log4net.Filter.LoggerMatchFilter"&gt;
        &lt;loggerToMatch value="Test" /&gt;
      &lt;/filter&gt;
      &lt;appendToFile value="true" /&gt;
      &lt;maxSizeRollBackups value="10" /&gt;
      &lt;maximumFileSize value="6MB" /&gt;
      &lt;rollingStyle value="Size" /&gt;
      &lt;staticLogFileName value="true" /&gt;
      &lt;filter type="log4net.Filter.DenyAllFilter" /&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%date [%thread] %-5level - %message%newline" /&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;
  </code></pre>