static void

WCF Logging

Tracing/Listeners

You can use standard tracing/listeners, although it's two-step

system.diagnostics

<system.diagnostics>
  <sources>
    <!-- sources are assembly name -->
    <source name="System.ServiceModel"
            switchValue="Information, ActivityTracing"
            propagateActivity="true">
      <!-- ActivityTracing is end to end tracing -->
      <listeners>
        <!-- specify type or sharedListener-->
        <add name="xml" />
      </listeners>
    </source>
    <source name="System.ServiceModel.MessageLogging">
      <listeners>
        <add name="xml" />
      </listeners>
    </source>
  </sources>
  <!-- using listeners by name -->
  <sharedListeners>
    <add name="xml"
         type="System.Diagnostics.XmlWriterTraceListener"
         initializeData="C:\log\Trace.svclog" />
  </sharedListeners>
  <!-- flush after every write (default is false)-->
  <trace autoflush="true"/>
</system.diagnostics>

messageLogging

<system.serviceModel>
  <diagnostics>
    <messageLogging
        logEntireMessage="true"
        logMalformedMessages="false"
        logMessagesAtServiceLevel="true"
        logMessagesAtTransportLevel="false"
        maxMessagesToLog="3000">
      <filters>
        <!--add xpath filter if rqd-->
      </filters>
    </messageLogging>
  </diagnostics>

Notes