Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trace all the calls (+ their stack) made to a WCF service

I have a WCF Service which is currently in Production. The code performance are not where we would like them to be and we are unable to reproduce in our Staging environment.

I was wondering if it is possible to log every single method call made to the service and by the service. Essentially I would like a sequential list of all the calls and time stamps (our code isn't multi-threaded).

Is there a way to achieve that without having to instrument the binaries. Is there a level of tracing under the system.diagnostic node in the web.config that we could change?

like image 950
Martin Avatar asked Feb 23 '23 05:02

Martin


1 Answers

Have you configured tracing in your configuration file? This is a good article on the subject.

Here is a sample configuration you can use and modify for your needs:

<system.diagnostics>
    <trace autoflush="true" />
    <sources>
        <source name="System.ServiceModel"
                switchValue="Information, ActivityTracing"
                propagateActivity="true">
            <listeners>
                <add name="ServiceModel"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="C:\ServiceModel.svclog" />
            </listeners>
        </source>
        <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="MessageLogging"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="C:\MessageLogging.svclog" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>

<system.serviceModel>
    <diagnostics>
        <messageLogging logEntireMessage="True"
                        logMalformedMessages="False"
                        logMessagesAtServiceLevel="True"
                        logMessagesAtTransportLevel="False"
                        maxMessagesToLog="10000"
                        maxSizeOfMessageToLog="10000" />
    </diagnostics>
</system.serviceModel>

Use the Service Trace Viewer Tool (SvcTraceViewer.exe) to view the resulting logs.

like image 148
Bernard Avatar answered Mar 10 '23 08:03

Bernard