Stack trace is not populated in rolling flat file

Topics: Exception Handling Application Block
Feb 23, 2012 at 1:31 PM

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General"> 
<listeners>   
<add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, &#xD;&#xA;&#xD;&#xA;Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, &#xD;&#xA;&#xD;&#xA;Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
    fileName="C:\log\services.log" formatter="Text Formatter"     
rollFileExistsBehavior="Increment" rollInterval="None" rollSizeKB="10"     
timeStampPattern="yyyy-MM-dd" maxArchivedFiles="1" />  </listeners> 
<formatters>  
 <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
    template="{message}"      name="Text Formatter" />  </formatters>
 <categorySources>    <add switchValue="All" name="General">      <listeners>        <add name="Rolling Flat File Trace Listener" />      </listeners>    </add>  </categorySources>  <specialSources>    <allEvents switchValue="All" name="All Events">      <listeners>        <add name="Event Log Listener" />        <add name="Rolling Flat File Trace Listener" />      </listeners>    </allEvents>    <notProcessed switchValue="All" name="Unprocessed Category">      <listeners>        <add name="Rolling Flat File Trace Listener" />      </listeners>    </notProcessed>    <errors switchValue="All" name="Logging Errors &amp; Warnings">    
 <listeners>        <add name="Rolling Flat File Trace Listener" />      </listeners>    </errors>  </specialSources></loggingConfiguration>
<exceptionHandling> 
<exceptionPolicies>
   <add name="WCF Exception Shielding">      <exceptionTypes>        <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, &#xD;&#xA;&#xD;&#xA;PublicKeyToken=b77a5c561934e089"          postHandlingAction="ThrowNewException">          <exceptionHandlers>            <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, &#xD;&#xA;&#xD;&#xA;Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"              exceptionMessage="WCF Service message" faultContractType="Common.Contracts.Service.ServiceFault, Common.Contracts.Service"              name="Fault Contract Exception Handler">              </add>            <add name="ogging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, &#xD;&#xA;&#xD;&#xA;Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, &#xD;&#xA;&#xD;&#xA;PublicKeyToken=31bf3856ad364e35"              logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling"              formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, &#xD;&#xA;&#xD;&#xA;Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"              priority="0" />          </exceptionHandlers>        </add>      </exceptionTypes>    </add>  </exceptionPolicies></exceptionHandling></configuration>

generates log like

----------------------------------------
HandlingInstanceID: 787412ff-b606-4b31-a3f1-387fec97b181
An exception of type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException' occurred and was caught.
-----------------------------------------------------------------------------------------------------------------------------------------
02/23/2012 14:18:12
Type : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Message : Attempted to divide by zero.
Source :
Help link :
FaultContract : Common.Contracts.Service.ServiceFault
Data : System.Collections.ListDictionaryInternal
TargetSite :
Stack Trace : The stack trace is unavailable.
Additional Info:

The serviceFault that contracts have has StackTrace as a datamember. when i catch the exception of type FaultException<ServiceFault>, I do get stack trace in e.detail.stacktrace.

But what I'm not understanding is, why is stack trace in above log empty? please help. i'm not sure what i'm doing wrong.

 

 

Feb 23, 2012 at 11:49 PM

I would recommend putting the logging handler before the FaultContractExceptionHandler.  Then you would see the StackTrace of the original exception instead of the information about the newly created, but not yet thrown, FaultContractWrapperException.  Since the FaultContractWrapperException is not yet thrown it does not have a StackTrace.

Also, I think everyone would find it easier to read the post if the configuration was formatted using the Insert Code Snippet functionality.  Thanks.  :)

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Feb 24, 2012 at 7:24 AM

Hi Randy,

Thanks for this. It worked now.

I wasn't laxing but the insert code pop up never works for me. I've tried on chrome, ie9. after pasting the config/code & when i click insert, the reply window is always empty. in other words, the code is never pasted to this window

this behaviour has been like this for over weeks now for me.  I wanted to raise a bug but wasn't sure where I can.

 

Kavya

Feb 24, 2012 at 2:49 PM

You're right -- it was broken a few weeks ago but I think they already fixed it. 

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com