管理與診斷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 > configuration 元素的屬性。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 wizard 來編輯設定。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)來建立和編輯使用 WIZARD 的 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