Wcf - Get request and response using System.Diagnostics
... Hello
I have WCF and I need to record a request and associated response.
Today I seem to be getting a request and a response, but I have no identifier to communicate.
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:
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 the request and response can be linked in one way or another?
thanks for the help
+3
source to share
1 answer
Diagnostics generate "Correlation Activity Id" in messages, the same queries and relationships and relationships.
This link has more information and may help you:
http://www.codeproject.com/Articles/392926/Grouping-application-traces-using-ActivityId
And this is about ActivityID:
http://www.thejoyofcode.com/Propagating_the_ActivityId_to_a_WCF_service.aspx
+1
source to share