Question

I have enabled tracing in a WCF service. Here is the system.diagnostics section:

<configuration>
  <system.diagnostics>
    <trace autoflush="true"/>
    <sources>
      <source name="System.ServiceModel" switchValue="All" propagateActivity="true">
        <listeners>
          <add name="xmlTraceListener" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="All">
        <listeners>
          <add name="xmlTraceListener" />              
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xmlTraceListener"
          type="System.Diagnostics.XmlWriterTraceListener"
          initializeData="C:\KryptonTracing\Traces.svclog" />
    </sharedListeners>
  </system.diagnostics>

Here is the system.serviceModel section showing diagnostics only:

<diagnostics wmiProviderEnabled="true">
  <messageLogging
       logEntireMessage="true"
       logMalformedMessages="true"
       logMessagesAtServiceLevel="true"
       logMessagesAtTransportLevel="true"
       maxMessagesToLog="3000"
   />
</diagnostics>

When I publish the service I see an Information event in the Windows Event Viewer on the server saying the following:

Message Logging has been turned on. Sensitive information may be logged in the clear, even if it was encrypted on the wire: for example, message bodies.

When I go to the C:\KryptonTracing folder on the server there is no Traces.svclog generated. I have gone into IIS and looked at the app pool identity this WCF service is running under and given that identity full control over the folder.. still nothing. No matter what I do I can't get anything to create a Traces.svclog. FYI, this service is wsHttpBinding (SSL) with custom authentication, but that should not matter.

I have tried everything in this post to no avail. Please help.

Was it helpful?

Solution

I ended up using the WCF Configuration Editor to add the tracing to the web.config. It generated these two sections in my web.config.

<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
      <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="C:\Tracing\Krypton_Web_messages.svclog"
           type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
           name="ServiceModelMessageLoggingListener" 
           traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
      <add initializeData="C:\Tracing\Krypton_Web_tracelog.svclog"
           type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
           name="ServiceModelTraceListener" 
           traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>

...and this:

<diagnostics>
  <messageLogging logEntireMessage="true" logMalformedMessages="true"
    logMessagesAtTransportLevel="true" />
</diagnostics>

Then, before publishing I went and created the C:\Tracing folder and added "Everyone" with full permissions. Finally I published and now the two .svclog files are in the folder!!!! Not sure why my original configuration didn't work to begin with.

OTHER TIPS

Having the same problem I noticed that the app.config gui editor was writing switchValue="Advertencia,ActivityTracing" in spanish (the VS locale I use).

I changed it to switchValue="Warning,ActivityTracing" and it worked. Log files are now created.
Search online for 'TraceLevel Enumeration' to see available options.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top