Logging WCF errors en debug info

I was getting data from a windows communication foundation (WCF) service in my Silverlight 4 application.

Deploying on the server didn’t work at once, of course.

The Silverlight messages indicated there was something going wrong server side, so i figured it was something with my data (wcf) service.

But what exactly was going wrong?

Then i read about WCF logging: add the following code to your web.config (dont’ forget to alter the path to one on your own disk) and voila, logging was ready!


 <system.diagnostics>      
     <sharedListeners>  
       <add name="WcfListener"  
               type="System.Diagnostics.XmlWriterTraceListener"  
               initializeData="c:\logs\wcfLog.svclog"  />  
     </sharedListeners>      
     <sources>        
       <!-- switchValue attribute has no impact on MessageLogging -->  
       <source name="System.ServiceModel.MessageLogging"> 
          <listeners> 
            <add name="WcfListener" /> 
          </listeners> 
        </source>       
        <source name="System.ServiceModel" 
                      switchValue="Warning, ActivityTracing" 
                      propagateActivity="true" > 
          <listeners> 
            <add name="WcfListener" /> 
          </listeners> 
        </source>       
      </sources>     
  </system.diagnostics> 
    
    
  <system.serviceModel> 
    <diagnostics> 
      <messageLogging  
           logEntireMessage="true"  
           logMalformedMessages="false" 
           logMessagesAtServiceLevel="true"  
           logMessagesAtTransportLevel="false" 
           maxMessagesToLog="3000" 
           maxSizeOfMessageToLog="2000"/> 
    </diagnostics> 
 </system.serviceModel>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s