我想这将是简单的,但我看不出如何告诉WCF登录邮件正文。我有:
I thought this would be simple, but I can't see how to tell WCF to log message bodies. I have:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Verbose">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EntLibLoggingProxyTraceListener,Microsoft.Practices.EnterpriseLibrary.Logging"
name="traceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false" />
</diagnostics>
...etc..,
...etc...
</system.Model>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add fileName="_trace-xml.log"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData,Microsoft.Practices.EnterpriseLibrary.Logging"
traceOutputOptions="None"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener,Microsoft.Practices.EnterpriseLibrary.Logging"
name="XML Trace Listener" />
...etc... other listeners
</listeners>
...etc...
</loggingConfiguration>
但我得到记录的东西是对的消息,而不是邮件正文。什么我需要改变日志消息的内容?
But all I get logged is stuff about the message, not the message body. What do I need to change to log message content?
如果您需要的邮件正文,你必须自己捕捉它们,编程。使用服务行为,安装一个消息检查和捕捉信息的执行IDispatchMessageInspector或IClientMessageInspector内。
If you need message bodies, you'll have to capture them yourself, programatically. Use a service behavior to install a message inspector and capture messages inside your implementation of IDispatchMessageInspector or IClientMessageInspector.