. Hello
I have a WCF and I have to record the request and the associated response.
Today I seem to get the request and response, but I have no ID to associate.
Using the following configuration in .config:
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="Ctx_Host.WebTraceListener, Ctx_Host" />
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="300000"
maxSizeOfMessageToLog="200000"/>
</diagnostics>
</system.serviceModel>
And the .cs code is :
public class WebTraceListener : TraceListener
{
public override void Write(string message)
{
using (var sw = new StreamWriter(@"F:\wcf\log.csv", true))
{
sw.WriteLine(message);
}
}
public override void WriteLine(string message)
{
using (var sw = new StreamWriter(@"F:\wcf\log.csv", true))
{
sw.WriteLine(message);
}
}
}
Can you tell me if it is possible to link the request and response in this way or another?
thanks for your help
The diagnostics generates a "Correlation ActivityID" in messages, it's the same and relation requests and responses.
This link has more information about and can help you:
http://www.codeproject.com/Articles/392926/Grouping-application-traces-using-ActivityId
And this about ActivityID:
http://www.thejoyofcode.com/Propagating_the_ActivityId_to_a_WCF_service.aspx