I got WCF REST Service and I want every message recived\sent from this service to be logged. In my app.config i got this configuration:
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
</system.serviceModel>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="logs\\messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
I`m using this binding for my service
WebHttpBinding basicWebBinding = new WebHttpBinding
{
MaxReceivedMessageSize = int.MaxValue,
MaxBufferSize = int.MaxValue,
MaxBufferPoolSize = int.MaxValue,
CloseTimeout = new TimeSpan(0, 3, 0),
OpenTimeout = new TimeSpan(0, 3, 0),
ReceiveTimeout = new TimeSpan(0, 3, 0),
TransferMode = TransferMode.Buffered,
SendTimeout = new TimeSpan(0, 3, 0),
WriteEncoding = Encoding.UTF8,
ReaderQuotas = new XmlDictionaryReaderQuotas()
{
MaxStringContentLength = int.MaxValue,
}
};
and this operation contract(yes, it emulates aspx page)
[OperationContract(Name = "process.aspx")]
[WebInvoke(Method = "POST",ResponseFormat = WebMessageFormat.Xml)]
Stream ProcessRequest(Stream data);
Everythig seems fine but i cant see any POST data for requests, for example
<MessageLogTraceRecord>
<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<Connection>keep-alive</Connection>
<Content-Length>123</Content-Length>
<Content-Type>application/x-www-form-urlencoded</Content-Type>
<Accept>text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8</Accept>
<Accept-Encoding>gzip, deflate</Accept-Encoding>
<Accept-Language>ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3</Accept-Language>
<Host>localhost</Host>
<Referer>http://localhost/...</Referer>
<User-Agent>Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0</User-Agent>
</WebHeaders>
</HttpRequest>
<Binary xmlns=""></Binary>
</MessageLogTraceRecord>
and response
<MessageLogTraceRecord>
<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<Connection>keep-alive</Connection>
<Content-Length>159</Content-Length>
<Content-Type>application/x-www-form-urlencoded</Content-Type>
<Accept>*/*</Accept>
<Accept-Encoding>gzip, deflate</Accept-Encoding>
<Accept-Language>ru</Accept-Language>
<Host>localhost...</Host>
<User-Agent>agent</User-Agent>
</WebHeaders>
</HttpRequest>... stream ...</MessageLogTraceRecord>
Any help on this would be nice.
My guess would be that the POST data is exceeding the default message logging length.
Have you tried adding maxSizeOfMessageToLog=”200000″ to the messageLogging element? (obviously you can set the size as required)
Here are settings I use successfully.
Cheers
Chris