title: Creating a rolling flat log file using Enterprise library
body: <p>In my web application I am trying to create a log file for logging errors and exceptions, but when I run my application, log file is not getting created in my solution folder or in bin folder.</p>
  
  <p>I used the following code. Please help me I am stuck up with this problem, thank you in advance.</p>
  
  <p><strong>namespaces used</strong></p>
  
  <pre><code>using Microsoft.Practices.EnterpriseLibrary.Logging;
  
  using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
  </code></pre>
  
  <p><strong>.cs file</strong></p>
  
  <pre><code>        public int GetdeskKMasterRecordsCount(string CircleId, string StoreId)
          {
              try
              {
                 throw new Exception("this is normal exception");
  
              }
              catch (Exception ex)
              {
                  BindLog(ex);
                  return 0;
              }
          }
  
  
          public static void BindLog(Exception ex)
          {
              if (ex == null) return;
              Logger.Write(LogInformation(1, DateTime.Now, ex.Message, " "));
  
          }
  
          public static LogEntry LogInformation(int eventId, DateTime timeStamp, string message, string documentName)
          {
              LogEntry logEntryObject = new LogEntry();
              logEntryObject.EventId = eventId;
              logEntryObject.Title = documentName;
              logEntryObject.TimeStamp = timeStamp;
              logEntryObject.MachineName = System.Environment.MachineName;
              logEntryObject.Message = message;
              logEntryObject.Categories.Add("Exception");
  
              return logEntryObject;
          }
  </code></pre>
  
  <p><strong>Web Config file</strong></p>
  
  <pre><code>&lt;configSections&gt;
      &lt;section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;
      &lt;section name="recordingWindowGroup" type="Vodafone.DMS.BAL.WindowConfigurationHandler, Vodafone.DMS.BAL"/&gt;
      &lt;section name="defaultParamGroup" type="Vodafone.DMS.BAL.DefaultParamConfiguration, Vodafone.DMS.BAL"/&gt;
      &lt;section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt;
    &lt;/configSections&gt;
    &lt;loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true"&gt;
      &lt;listeners&gt;
        &lt;add name="Rolling Flat File Trace Listener"
             type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
             listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
             fileName="Vodafone.DMS.log.exclude" footer="---------------------------" formatter="Text Formatter" header="---------------------------" rollFileExistsBehavior="Increment"
             rollSizeKB="10" timeStampPattern="yyyy-MM-dd hh:mm:ss" maxArchivedFiles="7" traceOutputOptions="Timestamp, Callstack" filter="All"/&gt;
      &lt;/listeners&gt;
      &lt;formatters&gt;
        &lt;add template="Timestamp: {timestamp}&amp;#xA;Message: {message}&amp;#xA;Category: {category}&amp;#xA;Priority: {priority}&amp;#xA;EventId: {eventid}&amp;#xA;Severity: {severity}&amp;#xA;Title:{title}&amp;#xA;Machine: {machine}&amp;#xA;Application Domain: {appDomain}&amp;#xA;Process Id: {processId}&amp;#xA;Process Name: {processName}&amp;#xA;Win32 Thread Id: {win32ThreadId}&amp;#xA;Thread Name: {threadName}&amp;#xA;"
             type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Text Formatter"/&gt;
      &lt;/formatters&gt;
      &lt;categorySources&gt;
        &lt;add switchValue="All" name="General"&gt;
          &lt;listeners&gt;
            &lt;add name="Rolling Flat File Trace Listener"/&gt;
          &lt;/listeners&gt;
        &lt;/add&gt;
      &lt;/categorySources&gt;
      &lt;specialSources&gt;
        &lt;allEvents switchValue="All" name="All Events"&gt;
          &lt;listeners&gt;
            &lt;add name="Rolling Flat File Trace Listener"/&gt;
          &lt;/listeners&gt;
        &lt;/allEvents&gt;
        &lt;notProcessed switchValue="All" name="Unprocessed Category"&gt;
          &lt;listeners&gt;
            &lt;add name="Rolling Flat File Trace Listener"/&gt;
          &lt;/listeners&gt;
        &lt;/notProcessed&gt;
        &lt;errors switchValue="All" name="Logging Errors &amp;amp; Warnings"&gt;
          &lt;listeners&gt;
            &lt;add name="Rolling Flat File Trace Listener"/&gt;
          &lt;/listeners&gt;
        &lt;/errors&gt;
      &lt;/specialSources&gt;
    &lt;/loggingConfiguration&gt;
  </code></pre>