トレースを有効にする方法

次の構成は、WCF トレースを有効にする方法を示しています。 具体的には、以下の方法について説明します。

  • サービス レベルとトランスポート レベルでメッセージをログに記録し、未処理の XML を接続時に調べる。

  • WCF 例外トレースを有効にして、メッセージ セキュリティ ヘッダー処理でエラーをキャプチャする。

  • ダイジェスト ログの作成を有効にすることにより、要約された基本的な情報を調べられるようにし、署名検証例外をわかりやすくする。

  • アクティビティ トレースを有効にすることにより、メッセージを相互に関連付け、どのステージで例外がスローされたかを識別できるようにする。

詳細については、「WIF トレース」を参照してください。

<configuration> <system.serviceModel> <diagnostics> <messageLogging maxMessagesToLog="30000" logEntireMessage="true" logMessagesAtServiceLevel="true" logMalformedMessages="true" logMessagesAtTransportLevel="true"> </messageLogging> </diagnostics> </system.serviceModel> <system.diagnostics> <sources> <!-- This section turns on digest logging, note that for this to work correctly, you need to add the following to machine.config: <system.serviceModel> <machineSettings enableLoggingKnownPii="true" /> </system.serviceModel> Search for 'DigestTrace' in the trace viewer to view the digest logs. --> <source name="System.IdentityModel" switchValue="Verbose" logKnownPii="true"> <listeners> <add name="xml" /> </listeners> </source> <!-- Log all messages in the 'Messages' tab of SvcTraceViewer. --> <source name="System.ServiceModel.MessageLogging"> <listeners> <add name="xml" /> </listeners> </source> <!-- ActivityTracing and propogateActivity are used to flesh out the 'Activities' tab in SvcTraceViewer to aid debugging. --> <source name="System.ServiceModel" switchValue="Error, ActivityTracing" propagateActivity="true"> <listeners> <add name="xml" /> </listeners> </source> <!-- This records Microsoft.IdentityModel generated traces, including exceptions thrown from the framework. --> <source name="Microsoft.IdentityModel" switchValue="Warning"> <listeners> <add name="xml" /> </listeners> </source> </sources> <sharedListeners> <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="trace.e2e" /> </sharedListeners> <trace autoflush="true" /> </system.diagnostics> </configuration>