管理和诊断Administration and Diagnostics

Windows Communication Foundation (WCF)提供了一组丰富的功能,可帮助你监视应用程序生命周期的不同阶段。Windows Communication Foundation (WCF) provides a rich set of functionalities that can help you monitor the different stages of an application’s life. 例如,您可以在部署时使用配置来设置服务和客户端。For example, you can use configuration to set up services and clients at deployment. WCF 包含大量性能计数器,可帮助你衡量应用程序的性能。WCF includes a large set of performance counters to help you gauge your application's performance. WCF 还通过 WCF Windows Management Instrumentation (WMI)提供程序在运行时公开服务的检测数据。WCF also exposes inspection data of a service at runtime through a WCF Windows Management Instrumentation (WMI) provider. 当应用程序出现错误或者开始错误操作时,可使用事件日志来了解是否有重大事件发生。When the application experiences a failure or starts acting improperly, you can use the Event Log to see if anything significant has occurred. 此外,还可以使用消息日志记录和跟踪来从头至尾查看应用程序中发生了哪些事件。You can also use Message Logging and Tracing to see what events are happening end-to-end in your application. 这些功能可帮助开发人员和 IT 专业人员对 WCF 应用程序的正常运行进行故障排除。These features assist both developers and IT professionals to troubleshoot an WCF application when it is not behaving correctly.

备注

如果收到的错误没有特定的详细信息,应启用includeExceptionDetailInFaults <serviceDebug >配置元素的属性。If you are receiving faults with no specific detail information, you should enable the includeExceptionDetailInFaults attribute of the <serviceDebug> configuration element. 这会指示 WCF 将异常详细信息发送到客户端,这使你能够在不需要更多高级诊断的情况下检测多个常见问题。This instructs WCF to send exception detail to clients, which enables you to detect many common problems without requiring more advanced diagnosis. 有关详细信息,请参阅发送和接收错误For more information, see Sending and Receiving Faults.

WCF 提供的诊断功能Diagnostics Features Provided by WCF

WCF 提供以下诊断功能:WCF provides the following diagnostics functionalities:

  • 端到端跟踪提供的检测数据可用于对应用程序进行故障排除而无需使用调试器。End-To-End tracing provides instrumentation data for troubleshooting an application without using a debugger. WCF 输出进程里程碑的跟踪以及错误消息。WCF outputs traces for process milestones, as well as error messages. 这可能包括打开通道工厂或者通过服务主机发送和接收消息。This can include opening a channel factory or sending and receiving messages by a service host. 可以为运行中的应用程序启用跟踪,以监视其进度。Tracing can be enabled for a running application to monitor its progress. 有关详细信息,请参阅跟踪主题。For more information, see the Tracing topic. 若要了解如何使用跟踪来调试应用程序,请参阅使用跟踪对应用程序进行故障排除主题。To understand how you can use tracing to debug your application, see the Using Tracing to Troubleshoot Your Application topic.

  • 消息日志记录用于查看消息在传输前后的情况。Message logging allows you to see how messages look both before and after transmission. 有关详细信息,请参阅消息日志记录主题。For more information, see the Message Logging topic.

  • 事件跟踪针对所有主要问题将事件写入事件日志。Event tracing writes events in the Event Log for any major issues. 然后,可以使用事件查看器检查任何异常情况。You can then use the Event Viewer to examine any abnormalities. 有关详细信息,请参阅事件日志记录主题。For more information, see the Event Logging topic.

  • 通过性能监视器公开的性能计数器可用于监视应用程序和系统的运行状况。Performance counters exposed through Performance Monitor enable you to monitor your application and system's health. 有关详细信息,请参阅性能计数器主题。For more information, see the Performance Counters topic.

  • System.ServiceModel.Configuration 命名空间用于加载配置文件和设置服务或客户端终结点。The System.ServiceModel.Configuration namespace allows you to load configuration files and set up a service or client endpoint. 如果必须将更新部署到很多计算机,可使用对象模型通过脚本对很多应用程序进行更改。You can use the object model to script changes to many applications when updates must be deployed to many computers. 或者,你可以使用 "配置编辑器" 工具(svcconfigeditor.exe)通过 GUI 向导编辑配置设置。Alternatively, you can use the Configuration Editor Tool (SvcConfigEditor.exe) to edit the configuration settings using a GUI wizard. 有关详细信息,请参阅配置应用程序主题。For more information, see the Configuring Your Application topic.

  • WMI 可用于查找哪些服务正在计算机上进行侦听,以及正在使用哪些绑定。WMI enables you to find out what services are listening on a machine and the bindings that are in use. 有关详细信息,请参阅使用诊断 Windows Management Instrumentation主题。For more information, see the Using Windows Management Instrumentation for Diagnostics topic.

WCF 还提供多个 GUI 和命令行工具,使您可以更轻松地创建、部署和管理 WCF 应用程序。WCF also provides several GUI and command line tools to make it easier for you to create, deploy, and manage WCF applications. 有关详细信息,请参阅Windows Communication Foundation 工具For more information, see Windows Communication Foundation Tools. 例如,您可以使用配置编辑器工具(svcconfigeditor.exe)通过向导来创建和编辑 WCF 配置设置,而不是直接编辑 XML。For example, you can use the Configuration Editor Tool (SvcConfigEditor.exe) to create and edit WCF configuration settings using a wizard, instead of editing XML directly. 你还可以使用服务跟踪查看器工具(svctraceviewer.exe)来查看、分组和筛选跟踪消息,以便能够诊断、修复和验证 WCF 服务的问题。You can also use the Service Trace Viewer Tool (SvcTraceViewer.exe) to view, group, and filter trace messages so that you can diagnose, repair, and verify issues with WCF services.

请参阅See also