WCF Trace Delay - wcf

I've configured WCF to log to a trace file and I am able to view the trace file in Microsoft Service Trace Viewer. Problem is there's a delay of approx 30 minutes between the messages being sent / received and the log record being written to file.
Anyone know why this may be?
Below I have pasted relevant content from btsntsvc64.exe.config
> <system.diagnostics>
> <sources>
> <source name="System.ServiceModel" switchValue="Verbose">
> <listeners>
> <add name="xml" />
> </listeners>
> </source>
> <source name="System.ServiceModel.MessageLogging" switchValue="Verbose, ActivityTracing">
> <listeners>
> <add name="xml" />
> </listeners>
> </source>
> <source name="System.Runtime.Serialization" switchValue="Verbose">
> <listeners>
> <add name="xml" />
> </listeners>
> </source>
> </sources>
> <sharedListeners>
> <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" traceOutputOptions="LogicalOperationStack"
> initializeData="C:\logs\BizTalk\WCFTrace.svclog" />
> </sharedListeners>
> <trace autoflush="true" /> </system.diagnostics> <system.serviceModel>
> <diagnostics>
> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true"
> logMessagesAtTransportLevel="false" />
> </diagnostics> </system.serviceModel>

Related

How to trace a specific endpoint on source System.Net

I'm trying to setup tracing for a specific endpoint in my WCF application.
I've tried with Filters on the "messageLogging" element in servicemodel, but it doesn't seem to apply on the sources System.Net and System.Net.Sockets.
I can't run tracing on all endpoints in production since it will add up to much storage. Doesnt anyone know how to filter the output to the listener to only include traffic on one specific endpoint?
My web.config looks like this:
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="System.Net">
<listeners>
<add name="TraceFile"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="TraceFile"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\Temp\TracingSystemNet.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="TraceFile" />
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
</switches>
</system.diagnostics>

WCF Tracing log message is set to false, but there is still a trace output being generated

I have the following configuration
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="false" logKnownPii="false" logMalformedMessages="false" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="false" maxMessagesToLog="250000000" maxSizeOfMessageToLog="262144000">
<filters>
<clear />
</filters>
</messageLogging>
<endToEndTracing propagateActivity="true" activityTracing="true" messageFlowTracing="true" />
</diagnostics>
<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Off, ActivityTracing">
<listeners>
<add name="RollingDateXmlWriterTraceListener" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Off">
<listeners>
<add name="RollingDateXmlWriterTraceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<!--<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\Temp\Logs\MainService.svclog" />-->
<add name="RollingDateXmlWriterTraceListener" type="XXX.Common.Listeners.RollingDateXmlWriterTraceListener, XXX.Common" traceOutputOptions="None" initializeData="C:\Temp\Logs\MainService.{yyyyMMdd}.svclog" />
</sharedListeners>
<trace autoflush="true" />
I have set false to all of the logMessage attributes, but i still get the svclog file. Do I miss something?

Logging Request and Response values for a WCF request in client

I am trying to log the request ad response messages in my client while the client is consuming a thirdparty WebService.
Despite of many attempts the log file - MessageLog.svclog never gets created using the following WCF configuration in the app.config file. Please help.
<system.diagnostics>
<sources>
<source
name="System.ServiceModel.MessageLogging"
switchValue="Information, ActivityTracing" >
<listeners>
<add name="yourTrace"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\Log\MessageLog.svclog">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging
logMessagesAtTransportLevel="true"
logMessagesAtServiceLevel="false"
logMalformedMessages="true"
logEntireMessage="true"
maxSizeOfMessageToLog="65535000" maxMessagesToLog="500" />
</diagnostics>
</system.serviceModel>
Thank you !
Try this. Notice the SharedListeners node
<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="C:\Log\MessageLog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
...
</system.serviceModel>
I had problem with WS Client tracing where App.config and folder permissions were totally ok. The solution in my case was that I renamed it to .exe.config (was built to .dll.config of the WS client dll). So make sure:
That the name in the folder of the config file matches the assembly name
That when you run/debug it, the assembly that config file is for, is really used and not assembly for other location.
If it is built into .dll.config it is maybe ignored cause it should be .exe.config.
-m

WCF: How do I trace message bodies?

I'm trying to diagnose a WCF service that is self-hosted in a relatively simple service host process (Service.exe).
I have Service.exe.config configured thus:
<?xml version="1.0" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="All"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\temp\Service.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging maxMessagesToLog="1"
maxSizeOfMessageToLog="2147483647"
logEntireMessage="true"
logMessagesAtServiceLevel="true"
logMalformedMessages="true"
logMessagesAtTransportLevel="true">
</messageLogging>
</diagnostics>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
When I look at the resulting svclog file, I see many trace events being logged (I expected only the first message to be logged), and none of the messages being traced show a message body (only headers).
I'm sure I must be missing something simple here, but I don't see it.
UPDATE: When I look at the WCF Config Editor, there are two sections under "Diagnostics": MessageLogging and Tracing. When I click the "EnableMessageLogging" link, my config file gets updated:
<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="All">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add initializeData="c:\temp\MessageBodyTracing.svclog" type="System.Diagnostics.XmlWriterTraceListener"
name="traceListener">
<filter type="" />
</add>
</listeners>
</source>
<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="c:\users\me\documents\visual studio 2010\projects\messagebodytracing\messagebodytracing\app_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
I guess the source named System.ServiceModel.MessageLogging is the key - I hadn't seen that in any documentation of message tracing...
Try to add:
<endToEndTracing propagateActivity="true" activityTracing="true" messageFlowTracing="true" />
in your diagnostics node, under messageLogging.
Set LogEntireMessage to true under Diagnostics->MessageLogging in the Service configuration Editor

How to enable tracing for WCF ajax enabled services?

How to enable tracing for WCF ajax enabled services? I have the following code:
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\logs\messages.svclog" />
</listeners>
</source>
</sources>
but it doesn't work.
thanks in advance.
Try like this:
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\logs\messages.svclog" />
</listeners>
</source>
</sources>