title: Could not load file or assembly 'log4net
body: <p>Ok I am having a very odd issue when deploying one of our web applications to our live servers.</p>
  
  <p>Our application uses log4net to log a lot of actions quite heavily and after a couple of hours after being deployed we get the following exception.</p>
  
  <p>Could not load file or assembly 'log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905' or one of its dependencies. Access is denied.</p>
  
  <p>Here are the relevant web.config additions I use.</p>
  
  <pre><code>&lt;configSections&gt;
      &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/&gt;
    &lt;/configSections&gt;
  
  &lt;log4net&gt;
      &lt;appender name="ErrorLogFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
        &lt;param name="File" value="D:\SomeLocation\Errorlog"/&gt;
        &lt;param name="AppendToFile" value="true"/&gt;
        &lt;param name="RollingStyle" value="Size"/&gt;
        &lt;param name="maxSizeRollBackups" value="-1" /&gt;
        &lt;param name="maximumFileSize" value="100MB" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/&gt;
        &lt;/layout&gt;
        &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
          &lt;param name="LevelMin" value="FATAL" /&gt;
          &lt;param name="LevelMax" value="FATAL" /&gt;
        &lt;/filter&gt;
      &lt;/appender&gt;
      &lt;appender name="BookingLogFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
        &lt;param name="File" value="D:\SomeLocation\BookingInfoLog"/&gt;
        &lt;param name="AppendToFile" value="true"/&gt;
        &lt;param name="RollingStyle" value="Size"/&gt;
        &lt;param name="maxSizeRollBackups" value="-1" /&gt;
        &lt;param name="maximumFileSize" value="100MB" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/&gt;
        &lt;/layout&gt;
        &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
          &lt;param name="LevelMin" value="INFO" /&gt;
          &lt;param name="LevelMax" value="FATAL" /&gt;
        &lt;/filter&gt;
      &lt;/appender&gt;
      &lt;root&gt;
        &lt;level value="ALL"/&gt;
        &lt;appender-ref ref="BookingLogFileAppender"/&gt;
        &lt;appender-ref ref="ErrorLogFileAppender"/&gt;
      &lt;/root&gt;
  
    &lt;/log4net&gt;
  </code></pre>
  
  <p>It is working fine on our local machines an dev server but just not on the live.</p>
  
  <p>Incidentally it seems to break after the JIT compiler runs on the server after a web.config update or an app pool recycle, or even just a long period of time!</p>
  
  <p><strong>UPDATE:</strong> Our live servers run all websites from a share location.  I managed to replicate this issue on another server running the application from a share.  When setting the site to run from a local drive the issue goes away but our hosting requires us to run from a share.  Any ideas why log4net would have permissions issues running from a share.  Again the app runs first time until another JIT compilation occurs</p>