Exceptions not logging to the Application Event log

Topics: Exception Handling Application Block
Jan 14, 2010 at 10:17 PM

Hi,

I am setting up WCF exception shielding on a service I am building.  In my exception policy I am trapping exceptions and sending them to both the Application Event log and a trace file log.

On my development machine (VS 2010) everything works fine.  Exceptions are recorded both in the Application event log and the trace file.

When I move the application to a pre-production test server (Windows Server 2003 and IIS) exceptions are not being recorded in the Application event log, but are showing up in the trace file.  The following is the exception handling section from the config file:

<exceptionPolicies>
      <add name="UI WCF Exception Shielding">
        <exceptionTypes>
          <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="ThrowNewException" name="Exception">
            <exceptionHandlers>
             
              <add logCategory="WCF Error Trace File Log" eventId="5000" severity="Error"
                title="UI WCF Error" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                priority="0" useDefaultLogger="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="UI WCF Logging Handler" />
    <add logCategory="Application Event Error Log" eventId="5000"
       severity="Error" title="UI WCF Exception" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
       priority="0" useDefaultLogger="true" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
       name="Application Logging Handler" />
              <add exceptionMessage="The UI WCF service application has encountered an unexpected problem.  Please check service server logs for details."
                faultContractType="ECL.WCFServices.UIServices.UIWCFFault, ECL.WCFServices.UIServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="Fault Contract Exception Handler">
                <mappings>
                  <add source="{Message}" name="Message" />
                  <add source="{GUID}" name="MessageID" />
                </mappings>
              </add>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>

Can't figure out why it will work on the dev box, but not the pre-production server.

Thanks.

Tim

 

Jan 15, 2010 at 2:14 AM

What's the os in your dev box?  I'm guessing its a permission issue.  Default permissions in windows server 2003 are more strict than in a win xp environment.  Check if you have rights writing to the event log and creating files.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

entlib.support@avanade.com

Jan 15, 2010 at 2:44 PM

Hi Sarah,

The pre-production server is running WIndows Server 2003 R2 SP2 with IIS.

I don't think it is a permissions issue.  I added a bit of test code to my application that writes an entry to the Application event log directly (without throwing an exception).  When I write the App event log entry this way it shows up.  Also I can write to the log files to the Documents and Settings\All Users\Application Data folders with no problems.

I will double check the permissions all the same.

Thanks and best regards,

Tim

 

Jan 19, 2010 at 7:27 AM

Are you using "Enterprise Library Logging" as the Source property of your event log trace listener?  If you are, another possible reason then is that that source does not exists in your production machine.  Did you run Install Instrumentation (InstallServices.bat)?

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

entlib.support@avanade.com