none
Trouble getting WCF diagnostic traces working (no output at all)

    Question

  • Debugging with Visual Studio 2008, I am getting a System.ServiceModel.ProtocolException and I wanted to have a look at the tracing info for troubleshooting that.

    PROBLEM: I am getting nothing written to my .svclog files.

    My WCF service is hosted in IIS (5.1 running on my Win XP SP3 dev machine) and it's web.config file contains:

    <system.serviceModel> 
            <diagnostics> 
                <messageLogging 
                     logEntireMessage="true" 
                     logMalformedMessages="true" 
                     logMessagesAtServiceLevel="true" 
                     logMessagesAtTransportLevel="true" 
                     maxMessagesToLog="3000" 
                     maxSizeOfMessageToLog="2000"/> 
            </diagnostics> 
    </system.serviceModel> 
    <system.diagnostics> 
            <sources> 
                <source name="System.ServiceModel" 
                        switchValue="Information, ActivityTracing" 
                        propagateActivity="true"
                    <listeners> 
                        <add name="traceListener" 
                            type="System.Diagnostics.XmlWriterTraceListener" 
                            initializeData"d:\logs\WCFserviceTrace.svclog" /> 
                    </listeners> 
                </source> 
            </sources> 
        </system.diagnostics> 

    My WCF client is just a simple web page whose web.config contains the same snippets as above except:

    initializeData= "d:\logs\WCFclientTrace.svclog" />

    For brevity, I've left out all the other System.ServiceModel elements I am using. At this point I am just trying to get something logged to these trace files so I can get on to the real problems in the "protocol exception".

    Can somebody suggest what I've overlooked or done incorrectly ?


    Friday, February 13, 2009 6:16 PM

Answers

  • Try the following things:
    - Set the switchValue to "Verbose" (or "Verbose, ActivityTracing") - that will cause more info to be traced
    - It's possible that the traces are being buffered and not flushed to the file; try adding <trace autoflush="true" /> under <system.diagnostics>
    - The message logs will not be traced to the file (you need another source under <system.diagnostics>, with name="System.ServiceModel.MessageLogging")

    One thing that I find useful when creating .config files for WCF apps is to use the svcconfigeditor.exe tool (it comes with the Windows SDK, or with Visual Studio 2008). After a few years working with WCF I still don't remember the config schema, I always rely on that tool for enabling traces for me.
    • Edited by Carlos Figueira Friday, February 13, 2009 9:27 PM more info
    • Proposed as answer by Carlos Figueira Saturday, February 14, 2009 12:02 AM
    • Marked as answer by Marco Zhou Friday, February 20, 2009 11:04 AM
    Friday, February 13, 2009 9:26 PM

All replies

  • Can you make sure that the account "NETWORK SERVICE" has write access to the d:\logs file? That's the account with which IIS 5.1 runs the ASP.NET/WCF processes. If it doesn't have write access it won't be able to create the traces.
    Friday, February 13, 2009 7:01 PM
  • Thanks! Excellent point. I created d:\logs and gave Full Control to NETWORK SERVICE and then ran the test again. Interestingly, I got 1 file created in this formerly empty directory:

    WCFserviceTrace.svclog

    ...but, it is EMPTY. I had switchValue set to hopefully pump out a lot of stuff. ??

    Also, I did not get anything traced from my client (i.e. I was expecting the creation of WCFclientTrace.svclog in the same folder.

    So, I guessed that maybe I need to authorize another account for the client side so I gave ASPNET full control on the d:\logs folder and tried again. Same result.

    The discussion of tracing I've read on a simple example they called SelfHost described a configuration of two .SVCLOG files (one for the server side and one for the client).

    My client is another project in my Visual Studio solution (a web app at http://localhost/WCFclient)

    Can you suggest why I'm not getting anything traced ? Thanks in advance for help.


    Friday, February 13, 2009 8:12 PM
  • Try the following things:
    - Set the switchValue to "Verbose" (or "Verbose, ActivityTracing") - that will cause more info to be traced
    - It's possible that the traces are being buffered and not flushed to the file; try adding <trace autoflush="true" /> under <system.diagnostics>
    - The message logs will not be traced to the file (you need another source under <system.diagnostics>, with name="System.ServiceModel.MessageLogging")

    One thing that I find useful when creating .config files for WCF apps is to use the svcconfigeditor.exe tool (it comes with the Windows SDK, or with Visual Studio 2008). After a few years working with WCF I still don't remember the config schema, I always rely on that tool for enabling traces for me.
    • Edited by Carlos Figueira Friday, February 13, 2009 9:27 PM more info
    • Proposed as answer by Carlos Figueira Saturday, February 14, 2009 12:02 AM
    • Marked as answer by Marco Zhou Friday, February 20, 2009 11:04 AM
    Friday, February 13, 2009 9:26 PM
  • Carlos, thank you very much. I did all 3 of the things you suggested and got my "service" .svclog written to and then I repeated those things for the client side and I got that populated with trace entries too.

    Now .... on to interpreting things!

    Thanks for all your help!
    Friday, February 13, 2009 9:54 PM
  • Try the following things:
    - Set the switchValue to "Verbose" (or "Verbose, ActivityTracing") - that will cause more info to be traced
    - It's possible that the traces are being buffered and not flushed to the file; try adding <trace autoflush="true" /> under <system.diagnostics>
    - The message logs will not be traced to the file (you need another source under <system.diagnostics>, with name="System.ServiceModel.MessageLogging")

    One thing that I find useful when creating .config files for WCF apps is to use the svcconfigeditor.exe tool (it comes with the Windows SDK, or with Visual Studio 2008). After a few years working with WCF I still don't remember the config schema, I always rely on that tool for enabling traces for me.

    I am having the same issue however I am on a Windows 7 machine running IIS 7.  I have tried the fixes suggested above (except I gave the IIS_IUSR account write permissions instead of 'NETWORK SERVICE' as I believe this is the account that IIS7 will use) to no avail.  No log file is written.  Do you have any more suggestions?
    Wednesday, April 14, 2010 8:47 PM