Tracing & Logging WCF Applications

WCF offers Tracing capabilities, but are turned off by default. To make use of WCF Tracing you will need to turn on the feature and make a few configurations to the .config files of the modules that you would like to trace.

Enabling Tracing via Service Configuration Editor

  1. In Visual Studio, open the solution that contains the projects that you would like to trace
  2. Right-click a .config file of a project that you want to trace, then select “Edit WCF Configuration”

    Open .config file with the SCE

  3. In the Service Configuration Editor, open the Diagnostics directory then click the “Enable MessageLogging” and “Enable Tracing” links

    Enable logging and tracing

  4. Click the “ServiceModelMessageLoggingListener and ServiceModelTraceListener links, then choose where you want the logs to be saved.

    Specify where you want your logs to be saved

  5. Click the “Message Logging” item in the left menu, then specify which messages you want to log

    Specify the messages you want to log

  6. Open the “Sources” directory, click the “System.ServiceModel” and “System.ServiceModel.MessageLogging” sub items, then set the “Trace level:” to Verbose (or whatever level you want)

    Set the Trace Levels to Verbose

  7. Save the configuration, then take a look at the .config file

    Tracing and Logging Configuration shown in the .config

You will want to enable Tracing and Logging on each .config file that you want to view logs for.

To view the logs, go to the path that you defined in Step 4.


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s