IIS Process Termination within w3wp

Aug 1, 2014 at 1:03 PM
Hi,
I am having a problem with the Logging Application Block with a Webservice hosted in IIS. If I create a simple for loop in a webservice method, with a basic Thread to sleep within the loop to simulate a long running process, say for 30 seconds. If I have the web.config details for the Logging Application block active and call this method from 2 clients, I am randomly getting a thread termination within IIS. If I take the Logging Application Block web.config section out it works 100%.

This is eliviated when using a web garden as the issue only happened with IIS serves the request on the same w3wp process ID.

Has anyone experienced this before?
Steven
Aug 1, 2014 at 11:25 PM
Are seeing this issue just by adding the logging section to the web.config without even using the Logging Application Block? Are you getting an exception?

Can you supply a sample application that reproduces the issue?

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Aug 4, 2014 at 9:31 AM
Hi,

Thanks for the reply. Yes correct, problem only present when we add the section to the web.config. I hope you are able to assist, since removing this on the live production site the servers have stabilized dramatically.

The following are the details:

Code:
                LogEntry oEntry = new LogEntry();
                oEntry.Message = sMessage;
                oEntry.Severity = System.Diagnostics.TraceEventType.Information;
                IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
                LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
                Logger.SetLogWriter(logWriterFactory.Create(),false);
                Logger.Write(oEntry);               
Section in Web.config
<configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="WMS Core" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        source="WebServices" formatter="Text Formatter" log="WMS Core"
        machineName="." traceOutputOptions="None" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.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="WMS Core" />
        </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="WMS Core" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
Aug 10, 2014 at 7:15 PM
Is the posted code:
               LogEntry oEntry = new LogEntry();
                oEntry.Message = sMessage;
                oEntry.Severity = System.Diagnostics.TraceEventType.Information;
                IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
                LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
                Logger.SetLogWriter(logWriterFactory.Create(),false);
                Logger.Write(oEntry);               
just sample code or is the code you use to log a message in the production system? If the latter then one problem is that you are creating a new LogWriter and setting it as the static facade LogWriter instance. SetLogWriter is not thread-safe and could cause problems with other threads that are in the middle of logging. Typically, the SetLogWriter call would be done once during application initialization.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to