0

Im trying to keep a log of all the calls to my WCF Restfull service. I need to be able to view method name, all the parameters that is passed to it, and any response (string, object, list)

Here is my set up in config file:

<system.serviceModel>
    <diagnostics>
  <messageLogging
       logEntireMessage="true"
       logMalformedMessages="true"
       logMessagesAtServiceLevel="false"
       logMessagesAtTransportLevel="true"
       maxMessagesToLog="2147483647"
       maxSizeOfMessageToLog="2147483647"/>
</diagnostics>

</system.serviceModel>
 <system.diagnostics>
<sources>
  <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing" propagateActivity="true">
    <listeners>
      <add name="ServiceModelTraceListener">
        <filter type=""/>
      </add>
    </listeners>
  </source>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="ServiceModelMessageLoggingListener">
        <filter type=""/>
      </add>
    </listeners>
  </source>
</sources>
<sharedListeners>
  <add initializeData="c:\Temp\Tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
    <filter type=""/>
  </add>
  <add initializeData="c:\Temp\Messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
    <filter type=""/>
  </add>
</sharedListeners>
<trace autoflush="true"/>

In the Messages.svclog file, Activity tab doesn't show calls to my Method . It only shows passed parameters in the body of Received message. Response message doesnt show Method name either, but I can see it under Action property.

In the Tracelog.svclog file, Activity tab does show calls to my Method, but it doesn't show any parameters that are passed or response object

How can I set it up to see my methods being called with parameters and its response?

1 Answer 1

1

You will need to extend WCF to inject your logging into it. You can provide your own IOperationInvoker which can log inputs and outputs from the call or you can use IParameterInspector. You can also take a look at The Enterprise Services Logbook from IDesign (you have to search for it on the page) or here is direct link.

Sign up to request clarification or add additional context in comments.

2 Comments

I was hoping for easier way to achieve it.
If you look at the links provided they give you complete examples on how to achieve implementation of the interceptions. They might look hard but it's fairly simple to add.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.