title: Log4net not working in IIS7 on windows server 2008
body: <p>Logs are not created on the server (Windows 2008) and IIS7.  I had given absolute path as well as relative path.</p>
  
  <p>I had given all rights to the log folder.  I had included network user, IUsr and IIS_IUSRS, and gave permission to every one. also.</p>
  
  <p>It is not writing logs to that folder</p>
  
  <p>the entries on the web config is as follows</p>
  
  <pre><code> &lt;section name="log4net"   type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /&gt;
  
   &lt;log4net&gt;
   &lt;logger name="GeneralLogger"&gt;
   &lt;level value="ALL" /&gt;
   &lt;appender-ref ref="RollingFile" /&gt;
   &lt;/logger&gt;
   &lt;appender name="RollingFile" type="log4net.Appender.RollingFileAppender"&gt;
   &lt;file value="C:\\vhosts\\staging.customerportal.com\\log\\CustomerPortal.log"/&gt;
   &lt;appendToFile value="true"/&gt;
   &lt;datePattern value="yyyyMMdd"/&gt;
   &lt;rollingStyle value="Date"/&gt;
   &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
   &lt;acceptOnMatch value="true"/&gt;
   &lt;levelMin value="DEBUG"/&gt;
   &lt;levelMax value="FATAL"/&gt;
   &lt;/filter&gt;
   &lt;layout type="log4net.Layout.PatternLayout"&gt;
   &lt;conversionPattern value="%-5p %d %5rms %X{addr} %-22.22c{1} %-18.18M - %m%n"/&gt;
   &lt;/layout&gt;
   &lt;/appender&gt;
   &lt;/log4net&gt;
  </code></pre>
  
  <p>I had tried giving single slash and well as double slash in the file value in web config nothing works.</p>
  
  <p>The code in the global.asax.cs is</p>
  
  <pre><code> public class MvcApplication : System.Web.HttpApplication
   {
     private static log4net.ILog log =   log4net.LogManager.GetLogger(typeof(MvcApplication));
  
      protected void Application_Start()
      { 
        log4net.Config.XmlConfigurator.Configure();
  
      }
  </code></pre>
  
  <p>code in assemblyinfo.cs is</p>
  
  <pre><code>   [assembly: XmlConfigurator(ConfigFile="web.config", Watch=true)]
  </code></pre>
  
  <p>I had tried with this code and also without this code in assemblyinfo.cs</p>
  
  <p>It is not working.</p>
  
  <p>Where as When I use absolute path in localhost the logs are written to that folder properly</p>
  
  <p>It fails on the server  </p>
  
  <p>I had tried both these options in the controller file</p>
  
  <pre><code>  //private static log4net.ILog log =     
          log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)      ;
     private static log4net.ILog log = log4net.LogManager.GetLogger("GeneralLogger");
  </code></pre>
  
  <p>I had tried a path which does not exists, it did not created folder.</p>
  
  <p>Please help me. Please help me how to enable logs using log4net in server</p>