<URGENT>Enterprise Library 3.1: Exceptions not logging in the file

Topics: Exception Handling Application Block, Logging Application Block
Oct 15, 2009 at 6:04 AM

Application doesn't log the exceptions in file. The same setting works fine on the dev machine but not on the test machine. I have also checked the file permission and file has READ/Write permission. Has anybody faced this issue before?

 

Thanks

DB

Oct 15, 2009 at 6:17 AM

Do you have a tracelistener configured under the Logging Errors and Warnings? If not, please add at least a FormattedEventLogTraceListener under it and check the event viewer whenever you didn't get a log to see what error occured if there's any.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 15, 2009 at 1:41 PM

Thanks for the quick response!

Yes, we have the tracelistener defined under the Logging Errors and Warnings: Please see the below setting.

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
   defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add fileName=" C:\tcf\trace.log" header="----------------------------------------"
        footer="----------------------------------------" formatter=""
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        name="FlatFile TraceListener" />
      <add source="Enterprise Library Logging" formatter="Text Formatter"
        log="Application" machineName="hydhtc47511" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="Formatted EventLog TraceListener" />
    </listeners>
    <formatters>
      <add template="Message         : {message}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="FlatFile TraceListener" />
        </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="Formatted EventLog TraceListener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>

<exceptionHandling>
    <exceptionPolicies>
      <add name="BIDPolicy">
        <exceptionTypes>
          <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="NotifyRethrow" name="Exception">
            <exceptionHandlers>
              <add logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
                formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                priority="0" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                name="Logging Handler" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling> 

 Could you please suggest what's wrong?

 

Thanks

Deepak

Oct 16, 2009 at 1:31 AM

Did you check the event viewer if there were any logs indicating why logging to the file failed?  Something like "Logging to trace source 'General' failed....

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 16, 2009 at 3:48 AM

Got the solution. Our solution was built using the one set of EntLib API's and the production server EntLib API set was having different Public Key.  Workaround was, compiled our solution by refering to the Production EntLib API's and then deployed it on production. It worked.

 

Thanks for all your help!

 

Cheers

Deepak