How to turn on debug exceptions with WCF

It is possible to see exceptions passed back in the messages sent to the service.  This makes it a lot easier to debug multi-peer applications.  The way to do this is to add into the web.config file the section.  You can see in the following config section that the behavior <serviceDebug includeExceptionDetailInFaults="true" /> is defined, this sets up the system to include exception details in the return faults. If you do this set this up, make sure you remove it when you deploy your code into the wild. Finding exception info can be used to find ways to exploit your server based on stack traces.

 

    <system.serviceModel>
        <services>
            <service name="OneCareStatus.LogUploadService" behaviorConfiguration="UploadServiceBehavior">
                <endpoint address="" contract="OneCareStatus.ILogUploadService" binding="wsHttpBinding" bindingConfiguration="myHttpBinding"/>
            </service>
            <service name="OneCareStatus.FamilySafetyService" behaviorConfiguration="UploadServiceBehavior">
                <endpoint address="" contract="WpcSettings.IWpcSettingsService" binding="wsHttpBinding" bindingConfiguration="myHttpBinding"/>
            </service>
        </services>
        <bindings>
            <wsHttpBinding>
        <binding name="myHttpBinding">
         <security mode="None" />
         <reliableSession enabled="true"/>
        </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="UploadServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>