Search code examples
.netwcfenterprise-libraryenterprise-library-5

Microsoft Enterprise Library 5.0 Logging only occurs on first few WCF method call


I am experiencing erratic logging when using Enterprise Library 5.0 Logging.

The issue is with a WCF 4.0 application hosted in IIS (7.5) running on Windows 2008 R2 Servers in a load balanced configuration. I am using Unity (2.0) for Dependency Injection. I have configured the library to log to rolling text file. The application uses AppFabricCache.

It seems that the logging succeeds in the first few calls following restart of the Web application hosting the service. Thereafter, no further logging is seen. I have either made an error in the configuration or there might be some contention in writing / flushing output to the text file. I understand that the Logging class operates in a thread safe way.

Below is the relevant part of the config file. Any thoughts appreciated. Thanks.

<loggingConfiguration name="loggingConfiguration" tracingEnabled="true" defaultCategory="General">
    <listeners>
       <add name="Rolling 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="d:\SOMEPATH\Logs\trace.log"
          formatter="Text Formatter"
          header="" footer=""
          timeStampPattern="yyyy-MM-dd hh:mm:ss.fff"
          traceOutputOptions="None"
          maxArchivedFiles="2000"
          rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="1024" />
    </listeners>
     <formatters>
        <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
         template="{timestamp(yyyyMMdd HH:mm:ss.fff)} - {message}"
         name="Text Formatter" />
     </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
           <add name="Rolling File Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
           <add name="Rolling File Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>  

Solution

  • Thanks to Turzo, I reconfigured to log errors to Flat File. I was then able to see error message detail. Part of the error message was access denied. Part of it related to file path not found / incorrect format. It turns out that the TimeStampPattern was incorrectly specified as it does not generate an accepted file name format. I changed it to: timeStampPattern="yyyyMMdd_hhmm" and now have rolling files generated.