开发者

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

开发者 https://www.devze.com 2023-04-03 16:36 出处:网络
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 configur

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=开发者_StackOverflow31bf3856ad364e35"
          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>  


One thing you should do is change the errors specialSource to not use the Rolling File Trace Listener. It should use another listener such as FlatFileTraceListener or EventLogTraceListener.

My guess as to what is going on is that an error is occurring writing your log entry (perhaps a permission problem trying to roll). But you don't see anything in the logs because the errors source is set to use the same listener that just failed so the logging of the error also fails.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号