WCF: Verbose PII Tracing


WCF PII Verbose tracing
====

Depending on app built, update the machine.config file

Add line:
<machineSettings enableLoggingKnownPii="true"/>

<!-- Sample -->
<system.serviceModel>
<machineSettings enableLoggingKnownPii="true"/>

OUTSIDE <System.ServiceModel> tag add below lines:

<system.diagnostics>
<sources>
<source logKnownPii="true" name="System.ServiceModel.MessageLogging"
switchValue="Verbose,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="c:\temp\app_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
<filter type="" />
</add>
<add initializeData="c:\temp\app_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>

INSIDE <System.ServiceModel> tag add below lines:

<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
<endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" />
</diagnostics>

ONCE DONE, we should see following entry in Event logs
============
PII logging has been turned on. Sensitive information will be logged in the clear.
Process Name: ConsoleApplication1.vshost
Process ID: 5996

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name="System.ServiceModel 4.0.0.0" />
<EventID Qualifiers="49153">107</EventID>
<Level>4</Level>
<Task>7</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2018-02-06T00:56:31.835601400Z" />
<EventRecordID>133301</EventRecordID>
<Channel>Application</Channel>
<Computer>CC.XX.XXX.XXX</Computer>
<Security UserID="XXX.XXX" />
</System>
- <EventData>
<Data>ConsoleApplication1.vshost</Data>
<Data>5996</Data>
</EventData>
</Event>

I hope this helps 🙂

Thanks

SS

Comments (0)

Skip to main content