不跟踪 WCF 服务(诊断跟踪)
我有一个调用 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" />
I have a client (a Unit Test) that call to WCF Service (hosting in debug mode in Console application).
I have an error in service but I dont know which. I need trace it, but not generate anything file svclog in client.
any suggestions , any sample code works ?
EDIT: I use logging EntLibrary 4.1. I think there are errors in configuration and WCF diagnostics Tracing not trace logs.
My config in Client is:
<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" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要将
switchValue
设置为All
——这将记录所有内容。 参阅此处下页表 2/3。)(请 如果服务器上出现错误,请将
元素添加到服务器的 web.config 文件而不是客户端的 web.config 文件中。如果错误出现在您的服务器上,那么您需要在那里进行跟踪。我认为如果您的服务出错,那么在客户端上进行跟踪不会为您提供与在服务器端进行跟踪一样多的信息。如果您可以提供有关您所看到的错误的更多信息,也会有所帮助。我会相应地更新我的答案。
希望这有帮助!
You may want to set your
switchValue
's toAll
-- that will log everything. (See table 2/3 down page here.)If you're error is on your server, add your
<diagnostics>
element to your server's web.config file instead of your client's web.config file. If the error is on your server, then you need to trace it there. I would think if your service is erroring out, then tracing on the client won't give you as much information as tracing on the server side.If you could provide more information about the error that you're seeing, that would also help. I'll update my answer accordingly.
Hope this helps!