C# 具有唯一Id的WCF诊断消息日志记录
我正在使用System.Diagnostics System.ServiceModel.MessageLogging和下面的配置记录WCF web服务的消息。我延长了时间 TraceListener类为:C# 具有唯一Id的WCF诊断消息日志记录,c#,wcf,logging,key,unique,C#,Wcf,Logging,Key,Unique,我正在使用System.Diagnostics System.ServiceModel.MessageLogging和下面的配置记录WCF web服务的消息。我延长了时间 TraceListener类为: public class FormattedTraceListener : TraceListener { static readonly Logger logger = new Logger(); public FormattedTraceListe
public class FormattedTraceListener : TraceListener
{
static readonly Logger logger = new Logger();
public FormattedTraceListener()
: base(string.Empty)
{
}
public override void TraceData(TraceEventCache eventCache,String source,TraceEventType eventType,**Int32 id,**Object data)
{
//....
....
/s:信封
/s:信封
TraceData方法为每个服务调用的请求和响应触发了两次。
但是,当命中方法时,id参数始终为0
我需要在日志文本中使用唯一的id来匹配请求和响应日志。我怎样才能指定呢?你的方法不对。TraceDataint id字段不是WCF请求的唯一id。它是事件类型的应用程序定义代码 只需使用标准的WCF跟踪类和。如果我了解您在将请求与响应匹配时要完成的任务,那么默认行为已经满足了您的需求