如何记录来自WCF请求的传入和传出XML [英] How to log incoming and outgoing XML from WCF requests
问题描述
我有一个基本的WCF托管在控制台应用程序中,还有一个基本的控制台WCF客户端.您如何看待两个应用程序之间(通过本地主机)发送的请求?
I have a basic WCF hosted in a console app, and a basic console WCF client. How do you look at the requests sent between the two apps (over localhost)?
我应该使用"Wireshark"之类的东西还是可以在Visual Studio中注销传入和传出的响应对象?
Should I use something like 'Wireshark' or would it be possible to log out the incoming and outgoing response objects in visual Studio?
我已经通过App.config文件中的system.diagnostics指令创建了 log.svclog
文件,但是找不到实际的请求和响应xml:
I'm already creating an log.svclog
file by the system.diagnostics directive in the App.config file, but can't find the actual request and response xml:
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\log\log.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
我是从Stack Overflow中获得的(我不记得在哪里)
Which I got from Stack Overflow (I can't remember where)
推荐答案
您需要配置消息日志记录,该消息记录与仅WCF跟踪是分开的,WCF跟踪是您在上面配置的.请参阅 https://msdn.microsoft.com/zh-cn/library/ms730064(v = vs.110).aspx .
You need to configure message logging, which is separate from just WCF tracing, which is what you have configured above. See https://msdn.microsoft.com/en-us/library/ms730064(v=vs.110).aspx.
这篇关于如何记录来自WCF请求的传入和传出XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!