3

I'm using System.Net tracing as described here:

http://ferozedaud.blogspot.com/2009/08/tracing-with-systemnet.html

But that traces every request made with HttpWebRequest. The trace file is huge. I only want to trace what happens when I am calling a certain URI eg:

https://api.example.com/oauth/RequestToken

Because connecting to this URI has problems after my web app has been running for several hours.

I want to ignore all requests to other URIs eg:

https://api.example.com/Foo

Because these requests are working fine, and are filling up the log with data that I do not need.

JK.
  • 21,477
  • 35
  • 135
  • 214
  • Are you using the svcTraceViewer tool to view the traces? It makes it much easier to wade through data rather than viewing the .xml trace output directly. – mellamokb Aug 10 '11 at 04:51
  • No I'm using TextWriterTraceListener to write to a text file. The problem is not just the huge amount of data, but the huge file size. So I would prefer to somehow stop it from writing everything. – JK. Aug 10 '11 at 06:12

1 Answers1

2

You might want to take a look at Message Filters (scroll down about half-way down the page to the section called "Message Filters".) Another page here dedicated solely to message logging filters. Here's an educated guess at what the configuration should look like for your example:

<messageLogging logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="true" >
   <filters>
        <add xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
                xmlns:a="http://www.w3.org/2005/08/addressing">
            /soap:Envelope/soap:Header/a:Action[starts-with(text(),'https://api.example.com/oauth/RequestToken')]
        </add>
   </filters>
</messageLogging>

There is also a custom implementation of a trace log filter here that might be helpful.

mellamokb
  • 56,094
  • 12
  • 110
  • 136