Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wcf trying to set up tracing to debug, not writing to log file

Tags:

trace

wcf

here's my web.config, running a WCF service in an application on IIS7, but nothing is being written to the specified file. permission on the file has been granted for everyone.

<system.diagnostics>
  <sources>
   <source name="System.ServiceModel" switchValue="Information, ActivityTracing,     error, warning, critical" propagateActivity="true">
    <listeners>
     <add name="traceListener"
  type="System.Diagnostics.TextWriterTraceListener"
  initializeData="c:\log\tracestext.log" />

    </listeners>
  </source>
  </sources>
 </system.diagnostics>

I can add a service reference just fine.
I then try to call the service from a windows app and, after a few minutes, get an error on the machine running the windows app "Client is unable to finish the security negotiation within the configured timeout (00:00:00). The current negotiation leg is 1 (00:00:00)."

but absolutely nothing is written to the trace log file specified in config.

Is there something else I need to do to enable tracing? thanks for your help

EDIT: "sources" section now matches the section recommended here: http://msdn.microsoft.com/en-us/library/aa702726.aspx

I've added the "diagnostics . messagelogging" section to "system.servicemodel"

and the event viewer shows: "Message Logging has been turned on. Sensitive information may be logged in the clear, even if it was encrypted on the wire: for example, message bodies. Process Name: w3wp Process ID: 1784 "

but the log file is still empty

like image 233
joey j Avatar asked May 17 '10 16:05

joey j


2 Answers

Yes - you've only just defined some .NET tracing source and listeners - but you haven't instructed WCF yet to actually do the tracing!

You also need:

<system.serviceModel>
    <diagnostics>
        <messageLogging 
            logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="false"
            logMalformedMessages="true" logEntireMessage="true"
            maxSizeOfMessageToLog="65535000" maxMessagesToLog="500" />
    </diagnostics>
</system.serviceModel>

These two sections of config combined should do it!

In order to get your messages written back to the log file right away, you might want to add a setting to your <system.diagnostics> section:

<system.diagnostics>
    ... everything you already have....

    <trace autoflush="true" />
</system.diagnostics>
like image 92
marc_s Avatar answered Oct 13 '22 00:10

marc_s


To write to the log file, make sure that identity running your web application has write access to the log directory.

You can find the identity in the IIS 7 management console. Select the application pool that your web application is using. Click on Advanced Settings... In the properties window, look for the identity field. It may say Network Service. This is the account that needs write permission to your log output folder.

If you already have a log file in this directory, try deleting it and letting the framework create it.

Hope this helps.

like image 39
Mark Good Avatar answered Oct 12 '22 23:10

Mark Good