Exception Logging is not working in production

Topics: Exception Handling Application Block, Logging Application Block
Sep 6, 2007 at 6:46 AM
Hi,
I am using Enterprise Library 3.1 Exception Handling Application block for logging exceptions to a flat file using Flat File Trace Listener. In my local system, its logging the exception properly but when I moved to production, its not working. I tried to give permissions to the folder of the file path. But its not working. Please help.
Here i am providing the web.config code:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="Trace" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add fileName="D:\trace.log" header="----------------------------------------"
footer="----------------------------------------" formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="Callstack" 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="" 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="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=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
<add switchValue="All" name="Trace">
<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 & Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<exceptionHandling>
<exceptionPolicies>
<add name="SPS Exception Policy">
<exceptionTypes>
<add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="NotifyRethrow" name="Exception">
<exceptionHandlers>
<add logCategory="Trace" eventId="100" severity="Error" title="SPS Exception Logging"
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>
Sep 6, 2007 at 1:38 PM
Hi,

What kind of trust setting are you using for your application?

Fernando
Sep 7, 2007 at 11:41 AM
Hi,
I am using Default trust for my application.


fsimonazzi wrote:
Hi,

What kind of trust setting are you using for your application?

Fernando

Sep 7, 2007 at 3:06 PM
Does the windows identity you use to run your application have permissions to write to the flat file?
Btw, if you enable instrumentation you should see entries in the event log describing the failure.

Fernando
Oct 11, 2007 at 10:44 PM
Hi Fernando,

I am using the Flat File Trace Listener to write to a text file, and i am specifying a certain folder to write the text file to, i am explicitly denying all permissions on that folder to the identity that is running the application because i want the access denied exception returned to me so that i can handle it in case this happens in production, but even with the permissions denied on the folder the application that does the logging will run and not return any errors and obviously since i denied permissions on the folder it does not write any log text files. Do you know why the Logging Application Block does not return any errors even when permissions are denied to writing to that folder? Thanks for any help that you can provide.

Devang
Oct 12, 2007 at 2:53 PM
Hi Devang,

The Logging block will not expose logging errors to the client application; instead will attempt to log the error to the location specified in the "errors" special source, falling back to the standard instrumentation mechanisms (perf counters, wmi and event log).

This is by design, to make logging as simple as possible for the application. The application logic is not expected to handle a logging issue; instead the block should be properly configured and the minimal permissions to access fallback instrumentation must be granted.

Regards,
Fernando