Geeks With Blogs
Steve Loethen When I grow up I want to code in c#

So far we have a contract, 2 client/server pairs (one programmatic and one administrative).  We can observe that the highly difficult tasks of text concatenation and changing case are happening.  But these examples are extremely trivial, and as we increase complexity, try new things, it would be nice to observer what is going on, especially when it does not go well.

Luck for us, there is a built in logging facility in .NET and a complete feature set and viewing tool specifically for WCF.  And all can be accomplished via the config file.  Let's hit the servers config file.

First, lets set up diagnostics...

    <source name="System.ServiceModel"
            switchValue="Information, ActivityTracing"
            propagateActivity="true" >
        <add name="xml"/>
    <source name="System.ServiceModel.MessageLogging">
        <add name="xml"/>
    <source name="myUserTraceSource"
            switchValue="Information, ActivityTracing">
        <add name="xml"/>
    <add name="xml"
               initializeData="d:\logs\Traces.svclog" />

This is straight out of the WCF help file.  It defines 3 sources, that use a common trace log, located at d:\logs\traces.svclog.  The first 2 come from system components, the third from a source I can drive.  We are not currently driving it yet, but let's leave it in so we can put stuff in it later for debugging purposes.

So, the trace destination is there.  Let's tell the WCF system to feed it.

The above big of config fell into the <configuration> section of our app.config.  The next bit is inside our System.ServiceModel section.

    <diagnostics wmiProviderEnabled="true">

As you can see, we have enabled several things here.  This produces a lot of good info about what is going on.  We see the entire message, both good and bad, at both the service and transport level.  You can trim this down.  As we run the service, it puts our tracing in our log file.  We could just open this file via Notepad, and brute force our way to knowledge, but guess what.  There is a better way.  svcTraceView.exe is part of the windows sdk.  This gives us nice formatted output.

<s:Envelope xmlns:s="">
<Action s:mustUnderstand="1" xmlns="">MyService/IMyContractInterface/SayHelloResponse</Action>
<SayHelloResponse xmlns="MyService">
<SayHelloResult>hello bob</SayHelloResult>

This is the message response from our "SayHello" method, which was given "bob" to append to the word "Hello ".   Not bad.

Technorati Tags: , ,

We will come back to this took and logging periodically to view the effects of binding and hosting changes...

For now....

Posted on Tuesday, June 26, 2007 1:16 PM VS.Net and development , Windows Communication Foundation | Back to top

Comments on this post: With all these messages flying about, what do they look like...

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Steve Loethen | Powered by: