Application block 2 and 3 failing in Production

Topics: Exception Handling Application Block, Logging Application Block
Apr 15, 2007 at 7:37 PM
Edited Apr 15, 2007 at 7:38 PM
Re: Logging Application block


Driving me mad this one :) so would really appreciate any help

Basically, I have a WCF service hosted in IIS that used the application block 2 and 3 (Thought by upgrading would resolve the issue - sadly it didnt) to log to the event log this worked fine on my machine for both build and release versions.

However, when it came to deployment to the production server none of the exceptions are written to the event log. This has got me completely stumped.

The web.config is being correctly retrieved because if I rename a policy the client comes up with an error.

Server code isnt doing any thing special i.e. :

bool rethrow = ExceptionPolicy.HandleException(ex, "Business Logic Policy");
if (rethrow)

and the policy part of the config file :

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

and the log part :

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<add source="Enterprise Library Logging" formatter="Text Formatter"
log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Formatted EventLog TraceListener" />
<add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter" />
<add switchValue="All" name="General">
<add name="Formatted EventLog TraceListener" />
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<add name="Formatted EventLog TraceListener" />

The only thing grasping at straws is something on the production server is disabling logging to the event log for my webservice.

Would greatly appreciate any hints as to why logging works fine on one machine and not on another. Many thanks for any help
Apr 16, 2007 at 5:26 PM
I'm guessing the issue is that the event source you have configured ("Enterprise Library Logging") does not exist on the production server. Creating event log sources requires administrator privileges which generally won't be granted to accounts running web applications. The "correct" way of dealing with this is to build an installer that will create the necessary event source; however a quick-and-dirty way is to manually run any application that logs to that source using an admin account. Once the event source is created the real app should be able to log to it using its limited privileges.

Apr 16, 2007 at 5:26 PM
Tracked it down - the user did not have permission to write to the event log on that machine. Annoying thing being there was no event entry or indication to point at that being the problem.

Apr 16, 2007 at 5:34 PM
:) posted at exactly the same time. And yes as you have correctly pointed out and my minds refreshed doing the installer thing for custom sources would be a good idea if I was not going to use the default Application Log. However, your info would have put me on the right track, just so much one has to remember sometimes lol. Just glad I got it sorted.

Not sure an installer can modify the permissions though - but happy enough to include a readme file to that effect