none
Tracing for WCF Service not working RRS feed

  • Question

  • Hi All,

    I followed this article to enable tracing for a WCF service hosted in IIS 7.0 on Windows 2008 R2.

    http://blogs.msdn.com/b/sridhara/archive/2010/04/06/tracing-sharepoint-2010-service-applications.aspx

    For some reason, when I invoke the service, log files are not generated. I have spent almost a day scratching my head as to why trace logs are not generated. I can confirm the app. pool identity has write access to the folder. Below is my tracing configuration from web.config file.

    <system.diagnostics>
        <sources>
          <source propagateActivity="true" name="System.ServiceModel.MessageLogging"
            switchValue="Information,ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelMessageLoggingListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
          <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing"
            propagateActivity="true">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelTraceListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add initializeData="C:\WCFLogs\web_messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
            <filter type="" />
          </add>
          <add initializeData="C:\WCFLogs\web_tracelog.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
            <filter type="" />
          </add>
        </sharedListeners>
        <trace autoflush="true" />
      </system.diagnostics>
      <system.serviceModel>
        <diagnostics>
          <messageLogging logEntireMessage="true" logMalformedMessages="true"
            logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true"
            maxMessagesToLog="3000" maxSizeOfMessageToLog="4000" />
        </diagnostics>

    Thursday, November 14, 2013 10:13 PM

Answers

  • Problem solved!

    WCF service was hosted in the context of a SharePoint web app. There is a web.config in SharePoint web app's virtual directory and a web.config in the svc directory where I hosted the service. All this while I was adding tracing configuration to svc dir's web.config. Once I made changes to web.config in web.app's virtual directory, tracing started working. So, web app web.config takes precedence over svc's web.config....interesting find!

    • Marked as answer by diffident Friday, November 15, 2013 12:05 AM
    Friday, November 15, 2013 12:04 AM

All replies

  • Problem solved!

    WCF service was hosted in the context of a SharePoint web app. There is a web.config in SharePoint web app's virtual directory and a web.config in the svc directory where I hosted the service. All this while I was adding tracing configuration to svc dir's web.config. Once I made changes to web.config in web.app's virtual directory, tracing started working. So, web app web.config takes precedence over svc's web.config....interesting find!

    • Marked as answer by diffident Friday, November 15, 2013 12:05 AM
    Friday, November 15, 2013 12:04 AM
  • Hi,

    Well Done.

    It is very kind of you to share your solution to us.
    If you have any other questions, welcome to post it in the WCF Forums.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 15, 2013 8:46 AM
    Moderator