0

我有一个调用 WCF 服务的客户端(单元测试)(在控制台应用程序中以调试模式托管)。

我在服务中有错误,但我不知道是哪个。我需要跟踪它,但不在客户端生成任何文件 svclog。

任何建议,任何示例代码都有效吗?

编辑:我使用记录 EntLibrary 4.1。我认为配置和 WCF 诊断中存在错误跟踪而不是跟踪日志。

我在客户端的配置是:

  <system.diagnostics configSource="Config\diagnostics.config" />

  <system.serviceModel>
    <behaviors configSource="Config\system.servicemodel.behaviors.config" />
    <bindings configSource="Config\system.servicemodel.bindings.config" />
    <client configSource="Config\system.servicemodel.client.config" />

    <diagnostics wmiProviderEnabled="false">
      <messageLogging logEntireMessage="true"
                logMalformedMessages="true"
                logMessagesAtServiceLevel="true"
                logMessagesAtTransportLevel="true"
               />

    </diagnostics>

  </system.serviceModel>


<system.diagnostics>
  <sources>
    <source name="System.ServiceModel" switchValue="Warning" propagateActivity="true" >
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>

    <source name="myUserTraceSource" switchValue="Warning, ActivityTracing">
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
  </sources>

  <sharedListeners>
    <add name="xml"
         type="System.Diagnostics.XmlWriterTraceListener"
         initializeData="TraceLog.svclog" />
  </sharedListeners>

</system.diagnostics>

  <loggingConfiguration configSource="Config\loggingConfiguration.config"/>

  <exceptionHandling configSource="Config\exceptionHandling.config" />
4

1 回答 1

2

您可能希望将switchValue's 设置为All-- 这将记录所有内容。(见表 2/3 下页这里。)

如果您的服务器上有错误,请将您的<diagnostics>元素添加到服务器的 web.config 文件而不是客户端的 web.config 文件中。如果错误在您的服务器上,那么您需要在那里跟踪它。我认为如果您的服务出错,那么在客户端上进行跟踪不会像在服务器端进行跟踪那样为您提供尽可能多的信息。

如果您可以提供有关您所看到的错误的更多信息,那也会有所帮助。我会相应地更新我的答案。

希望这可以帮助!

于 2010-08-26T17:40:16.597 回答