Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Book Excerpt: Essential Windows Communication Foundation (WCF) for .NET Framework 3.5 : Page 5

This revamped book covers developing with the latest release of WCF in Visual Studio 2008 on the .NET Framework 3.5, giving practical advice, numerous examples, tips and tricks, and ways to avoid the "pain points" of WCF development. Chapter 9 covers WCF Diagnostics.


advertisement
Using the Service Configuration Editor
So far this chapter has discussed manual XML-based methods of updating configuration files to enable tracing and message logging. In practice, there's an easier and less error-prone way to add and modify configuration settings using the SDK tool, Service Configuration Editor. If the Window SDK has been installed, this editor can be found under All Programs → Microsoft Windows SDK → Tools. However, in Visual Studio you can quickly launch the editor by right-clicking a configuration file and choosing Edit WCF Configuration. Let's use the Service Configuration Editor on the service project's App.config file. Right-click the SelfHost service project's App.config file, choose Edit WCF Configuration, and select the Diagnostics node from the Configuration pane.

To enable message logging and tracing, click the "Enable MessageLogging" and "Enable Tracing" hyperlinks. Doing so will configure the system as shown in Figure 1.

 
Figure 1. Tracing and Message Logging Enabled
Notice that the listeners and sources are now displayed in the left panel. You can now click the hyperlinks in each section to configure other related options.

Tracing Options
Once tracing is enabled, explore the available options by clicking the link next to the Trace Level label. Here you can elect to enable activity propagation and tracing (described earlier in this chapter, and both are typically enabled) as well as the verbosity level from Off through Verbose. Remember that the trace level will affect the amount of space consumed by trace logs. A large log is more difficult to navigate, so you should typically choose the least verbose level necessary.



Logging Options

 
Figure 2. Advanced Message Logging Settings
To access the Message Logging Settings dialog, click the link next to the Log Level label in the MessageLogging section. As described earlier, you can choose to log any of three types of messages: those that are malformed, messages as they are received or sent by the service level, and messages as they are ready for transport or just received from transport. Clicking the Message Logging item inside the Diagnostics node on the left panel will show the advanced logging settings options shown in Figure 2.

These options affect the behavior of the ServiceModel.MessageLogging source. They relate directly to the <messageLogging> configuration node, the defaults and purposes of which were shown previously in Table 9.2.

 
Figure 3 Message Logging XPath Filter
Earlier, we showed that message logging supports the concept of filters to log only those messages that pass specified XPath filters. The Message Logging node in the Service Configuration Editor exposes a New XPath Filter option in the Tasks pane. Figure 3 shows the same XPath filter we used earlier defined in the Service Configuration Editor.

The tool lets you specify the maximum number of nodes to search (the nodeQuota attribute) and lists commonly used namespaces, along with the prefix for each. You can add more namespaces if you need and reference them via the prefix in your XPath expression. Configuring Sources
Enabling tracing and logging via the Service Configuration Editor will automatically configure the System.ServiceModel and System.ServiceModel.MessageLogging trace sources. To see them, expand the Diagnostics/Sources node in the Configuration pane. Select the System.ServiceModel source and you will see the settings shown in Figure 4.

 
Figure 4. Trace Source Settings
On this screen, you can view or change the verbosity level as well as whether activity tracing and propagation will be used. Note that activity tracing and propagation are available only for tracing listeners and not for message logging listeners. Configuring Listeners
Returning to the main diagnostics screen (shown in Figure 1), you can access detailed listener settings by clicking the links for each listener name (for example, ServiceModelTraceListener). These options, shown in Figure 5, enable you to specify the target file for the listener as well as multiple options for the details included with each trace or message.

The check boxes relate to the System.Diagnostics.TraceOptions enumeration. The basic options are to include Timestamp, Process ID, Thread ID, Callstack, and/or DateTime of the trace. The Logical Operation Stack includes the correlation "stack" of the trace, essentially the correlated history of the trace, which is not necessarily the same as the environmental callstack.

 
Figure 5. Listener Settings
 
Figure 6. Detailed Listener Configuration

For a summary of each listener's settings, expand the Listeners node in the Configuration pane and click a listener. This displays the option summary for each listener, shown in Figure 6.

Here you can quickly review or change all the listeners' configuration options.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date