如果在开发过程中,WCF服务出现问题,我们可以通过服务引用,然后直接断点调试进去。然而,对于已经发布的服务,出现错误时,寻找错误信息会变得麻烦。

幸好,微软提供了服务跟踪查看器工具 (SvcTraceViewer.exe)这个工具来跟踪已发布的服务。

可以在文件夹: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin找到(我的系统是WIN7,.NET 4.0)

配置服务跟踪相当简单,可以用上面的SvcConfigEditor.exe来打开服务的config文件配置。

也可以手动修改配置,增加一个diagnostics的配置节点。

<?xml version="1.0" encoding="utf-8"?>
<configuration> <system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<!--添加跟踪节点-->
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="ServiceProxyBinding" closeTimeout="00:10:00" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" />
</binding>
<binding name="BasicHttpBinding_IAircraftService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" />
<binding name="BasicHttpBinding_ITransCenter" />
<binding name="BasicHttpBinding_IDecodeService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.85.70:5596/TransCenterSer.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransCenter"
contract="TransCenterSer.ITransCenter" name="BasicHttpBinding_ITransCenter" />
<endpoint address="http://192.168.85.70:8010/AHMTService/DecodeService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDecodeService"
contract="DecodeService.IDecodeService" name="BasicHttpBinding_IDecodeService" />
</client>
</system.serviceModel>
<!--配置跟踪节点-->
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="D:\LogData\MoveQarData_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="D:\LogData\MoveQarData_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>

参考:http://msdn.microsoft.com/zh-cn/library/ms732023.aspx

http://www.cnblogs.com/cbcye/archive/2009/06/02/1494734.html

http://www.cnblogs.com/cnblogsfans/archive/2009/03/16/1413069.html

最新文章

  1. CentOS6.3连接Xshell出现的问题(连接失败--需要设置ONBOOT=“yes”,开启网卡驱动)
  2. C# 通过代理获取url数据
  3. IOS 单例模式的写法
  4. Windows Azure 入门系列课程Windows Azure 入门系列课程
  5. HTTP 协议的头部
  6. block引发的陷阱
  7. 深入理解Java内存模型(六)——final
  8. 如何使用C#操作快捷方式(获取快捷方式属性、创建快捷方式)
  9. 模拟请求之 HTTP_Request2
  10. codevs 1243 网络提速
  11. write a macro to judge big endian or little endian
  12. BZOJ 1009: [HNOI2008]GT考试( dp + 矩阵快速幂 + kmp )
  13. 再起航,我的学习笔记之JavaScript设计模式17(模板方法模式)
  14. git应用
  15. jquery中文档处理的总结
  16. vue使用tips记录
  17. 02-jQuery的选择器
  18. redis知识点杂记
  19. nodejs安装 淘宝镜像
  20. PHP 调试利器之 PHPDBG

热门文章

  1. vc++6.0各种报错合集(附:VC++6.0调出打印窗口的方法)
  2. Timestamp 使用
  3. 【C语言入门教程】4.6 指针 和 数组
  4. Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.4.7 + MySQL 5.6.26 笔记
  5. Swift3.0P1 语法指南——集合类型
  6. Redis学习笔记九:独立功能之慢查询日志
  7. Effective Java 读书笔记之七 通用程序设计
  8. 面向对象的 CSS (OOCSS)
  9. Windows8笔记
  10. 18 TaskScheduler任务调度器抽象基类——Live555源码阅读(一)任务调度相关类