开发者

SOAP message is empty when catching MessageLoggingTraceRecords with CustomTraceListener

I want to write CustomTraceListener which writes all data to SQL Server DB. Here's the stub for it:

public class SqlTraceListener : TraceListener 
{
    public SqlTraceListener()
        : base开发者_StackOverflow()
    { }

    public SqlTraceListener(String name)
        : base(name)
    { }

    protected override string[] GetSupportedAttributes()
    {
        List<string> attributes = new List<string>();
        attributes.Add("connectionString");
        attributes.Add("actionFilter");
        attributes.Add("hostFilter");
        return base.GetSupportedAttributes();
    }

    public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
    {  }//Other empty methods...

}

In overridden method TraceData I want to catch SOAP messages sent to my WCF service. But when I check what is in "data" parameter I get this: (sorry for posting xml as pictures - it seems SO editor doesn't allow some xml keywords in posts):

SOAP message is empty when catching MessageLoggingTraceRecords with CustomTraceListener

But according to standard XmlWriterTraceListener I should get this:

SOAP message is empty when catching MessageLoggingTraceRecords with CustomTraceListener

How to configure TraceListener not to eliminate SOAP messages? My config is here:

  <system.diagnostics>
<sources>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="xml"/>
      <add name="sql"/>
    </listeners>
  </source>
</sources>
<sharedListeners>
  <add initializeData="C:\logs\StockPriceService.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="xml"/>
  <add type="SqlTraceListener.SqlTraceListener, SqlTraceListener" name="sql"/>
</sharedListeners>
<trace autoflush="true"/>


Is there any reason you're not using the out of the box database trace listener? See: Enterprise Library Database Trace Listener?.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜