LogWriterFailureEventID = 6352

Topics: Exception Handling Application Block, Logging Application Block
Feb 23, 2012 at 10:11 PM

Howdy,

I am just trying to get started with Enterprise Library 5 and was following along with the documentation @ http://msdn.microsoft.com/en-us/library/ff953192%28v=pandp.50%29.aspx.  Following the directions in the section "Diving in with a Simple Example" I have added an exception handler with both a Wrap Handler and a Logging Exception Handler.  This of course created a Logging Block.

When I try and create the Logging block in code with something like this:

        LogWriter _logWriter;
       _logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();

It executes fine but when I browse into the _logWriter object it shows a property called LogWriterFailureEventID = 6352.  I have no events in my event log to explain what the problem is.

Does anybody know what would cause this?  I am using Visual Studio 2010, I have the "Optional Update 1" installed as well.  This is a WCF Webservice application.

Thanks

dbl

Feb 24, 2012 at 12:26 AM

Hi,

LogWriterFailureEventID is actually a constant (set to 6352) that is used as the event ID when an error occurs.  Just seeing it in the object during debugging doesn't indicate that an error occurred.  Although, an error probably did occur. 

If you are using the configuration tool the errors specialSources defaults to the Event Log Trace Listener.  

The Event Log Trace Listener can frequently encounter permission issues when running under ASP.NET.  The reason is that ASP.NET doesn't have permission to create any new event sources (e.g. "Enterprise Library Logging") specified in the configuration.  The workaround is usually to pre-create the necessary event sources.  One way to do this would be to log a message using a program or script that has appropriate permissions (write permission on the registry). 

I always recommend setting the errors specialSources to a FlatFileTraceListener that is writing to a directory that is known to have the correct permissions.  Once configured any errors will be written to the trace listener associated with the errors specialSources.

The errors specialSources configuration would look like this:

  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        source="Enterprise Library Logging" formatter="Text Formatter"
        log="" machineName="." traceOutputOptions="None" />
      <add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        fileName="trace.log" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
        name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Event Log Listener" />
        </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="Flat File Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>

Once you have the above configured you should be able to see the actual error that is occurring in the file trace.log.

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