WCF日志跟踪SvcTraceViewer.exe

参考:

https://msdn.microsoft.com/zh-cn/library/ms732023.aspx

https://msdn.microsoft.com/zh-cn/library/ms751526(v=vs.100).aspx

SvcTraceViewer.exe文件位置:C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin

跟踪配置:

1. WCF配置文件<configuration>节点添加如下内容

 1 <system.diagnostics>
 2         <sources>
 3             <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
 4                 <listeners>
 5                     <add type="System.Diagnostics.DefaultTraceListener" name="Default">
 6                         <filter type="" />
 7                     </add>
 8                     <add name="ServiceModelMessageLoggingListener">
 9                         <filter type="" />
10                     </add>
11                 </listeners>
12             </source>
13             <source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
14               propagateActivity="true">
15                 <listeners>
16                     <add type="System.Diagnostics.DefaultTraceListener" name="Default">
17                         <filter type="" />
18                     </add>
19                     <add name="ServiceModelTraceListener">
20                         <filter type="" />
21                     </add>
22                 </listeners>
23             </source>
24         </sources>
25         <sharedListeners>
26             <add initializeData="messages.svclog"  type="System.Diagnostics.XmlWriterTraceListener"  name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
27             </add>
28             <add initializeData="tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener"  name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
29             </add>
30         </sharedListeners>
31         <trace autoflush="true" />
32     </system.diagnostics>
system.diagnostics

2. WCF配置文件<system.serviceModel>节点添加如下内容

1 <diagnostics>
2     <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtTransportLevel="true" />
3 </diagnostics>
diagnostics

 

跟踪日志查看:

服务启动后根目录会增加两个文件如下:

 

启动SvcTraceViewer.exe工具

打开messages.svclog / tracelog.svclog文件,左侧可以看到服务的调用记录,点击可以查看函数执行情况

 

posted @ 2015-07-02 14:46  J.Y  阅读(707)  评论(0编辑  收藏  举报