Message Logging with sqlBinding
Hello all,
I am trying to setup Message Logging for messages that are received by receive locations using WCF-SQL adapter or WCF-Custom with sqlBindings. What I observed is that if I set logMessagesAtTransportLevel="true" and logMessagesAtServiceLevel="false",
no messages are logged. If I set logMessagesAtServiceLevel="true" I have a log entry, but the message body is not displayed: <s:Body>...</s:Body>. I can't figure out how to log message bodies when using sqlBinding. Is it even possible?
Do you have any suggestions or recommendations for this? Thanks.
Dmitriy
January 30th, 2015 7:45pm
Why are you trying to do it that way?
In BizTalk, the correct way is to enable Message Tracking on the Port.
January 30th, 2015 7:55pm
I am trying to use WCF Trace Logging and not use message body tracking in BizTalk.
January 30th, 2015 8:02pm
Match your configuration with below:
<configuration>
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="300000"
maxSizeOfMessageToLog="200000"
/>
</diagnostics>
</system.serviceModel>
</configuration>
you can also write to file location by using:
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\logs\messages.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
If this doesn't work I would advice you to refer Message Logging and check what you are missing.
Rachit
January 30th, 2015 8:19pm
Hi Rachit,
Thanks for your reply. Unfortunately this is exactly what I have in my configuration. The Message Log Trace I get is this:
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>0</EventID>
<Type>3</Type>
<SubType Name="Information">0</SubType>
<Level>8</Level>
<TimeCreated SystemTime="2015-01-30T17:36:28.6070461Z" />
<Source Name="System.ServiceModel.MessageLogging" />
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="BTSNTSvc" ProcessID="12824" ThreadID="22" />
<Channel />
<Computer>R01-B6549F92DF</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<MessageLogTraceRecord Time="2015-01-30T12:36:28.6010455-05:00" Source="ServiceLevelReceiveDatagram" Type="Microsoft.Adapters.AdapterUtilities.AdapterMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action s:mustUnderstand="1">XmlPolling</a:Action>
<a:To s:mustUnderstand="1">mssql://r01-b6549f92df//Test?InboundID=Test</a:To>
</s:Header>
<s:Body>...</s:Body>
</s:Envelope>
</MessageLogTraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
As you can see the Body is not displayed (...).
January 30th, 2015 8:41pm
I do have switchValue set to "All".
January 30th, 2015 9:42pm
Ideally it should work.
Still, Refer this article on 4
simple steps to enable tracing in WCF
I would also advice you to restart the Host instance and try, could be that latest configuration is not loaded properly.
Rachit
January 30th, 2015 9:54pm
Thanks a lot Rachit for all your suggestions. For some reason this is only an issue for sqlBinding. I used exactly the same logging configuration with wsHttpBinding and basicHttpBinding and it works great. I suspect it may be related to streaming if that's what
sql adapter does, but I am not sure because I have seen log entries <s:Body>...stream...</s:Body> when streaming is used; in this case it looks like this: <s:Body>...</s:Body>
January 30th, 2015 10:13pm
I found this.
The following warnings apply specifically to the messages that are exchanged between a client application and the SQL adapter:
- WCF diagnostic tracing can log the header (but not the body) of messages exchanged with the SQL adapter. Because the message action is in the message header, this reveals the operations invoked on the SQL adapter by the client.
- If WCF message logging is enabled and logMessagesAtServiceLevel is true, the message header (but not the message body) of messages exchanged between the adapter client and the SQL adapter are logged.
Because the message action is in the message header, this reveals the operations that the client invoked on the SQL adapter. If logEntireMessage is also true, the message body will be logged. This can reveal
sensitive database information.
Refer: https://msdn.microsoft.com/en-us/library/dd788499.aspx
You might need to enable Logging Sensitive Information.
Refer: https://msdn.microsoft.com/en-us/library/ms730318.aspx
Rachit
January 30th, 2015 10:48pm
That was an interesting article. I followed this article to set enableLoggingKnownPii="true". Unfortunately still no luck. :-(
January 30th, 2015 11:27pm