c# - System.Net (HttpWebRequest) tracing without using files or app.config? -


I want to capture, but not all, HTTP WebRCC traffic in my application for debugging purposes by this IIS Hosted is a web service.

I have read that it works very well, but I do not want to direct trace a file due to possible permissions problems, data sensitivity, etc. on the file system. I would like to capture some of the storage that I can see later or encrypt and email preferably, there will not be any changes in the app.config file.

I tried the following, but obviously I'm missing a step to tie TextWriterTraceListener in SystemWind. How Can I Capture System.Net Traffic in My StringWriter?

  stringwriters SW = new stringwriters (); TextDrintress Listener Mary Listener = New Text Worker Tres Lisener (SH); Trace.Listeners.Add (myListener); HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.microsoft.com"); HttpWebResponse resp = (HttpWebResponse) req.GetResponse (); Stream s = resp.getResponseStream (); Byte [] buf = new byte [4096]; While (s.Read (buf, 0, buf.Length)> 0); S.Close (); MyListener.Flush (); Sw.flush (); Edit: Especially, I want to equal the runtime, except that I do not want to go to the network.log on the output, I want to go to string buffer I have set up for this purpose.  
  & lt; Configuration & gt; & Lt; System.diagnostics & gt; & Lt; Sources & gt; & Lt; Source Name = "System.Net.Sockets" Tracemolode = "Join" & gt; & Lt; Listeners & gt; & Lt; Add name = "System.Net.Sockets" type = "System.Diagnostics.TextWriterTraceListener" initializeData = "network.log" /> & Lt; / Listeners & gt; & Lt; / Source & gt; & Lt; / Sources & gt; & Lt; Switch & gt; & Lt; Add name = "System.Net.Sockets" value = "Verbose" /> & Lt; / Switch & gt; & Lt; Trace autoflush = "true" /> & Lt; /system.diagnostics> & Lt; / Configuration & gt;  

You can create your own trace listener implementation I found online that runs- Configures things in time. System does not work with trace sources. If you do not consider your hands dirty then you can try using reflection to toggle the personal static bool System.Net.Logging.s_LoggingEnabled (. NET 2).

For example, the following article and switch is by sending an e-mail to publish a static event, when you are interested in receiving trace messages, you can subscribe:

Since its logging is enabled its display is affected at all times (not all or anything as configured in web.config) (default trace for improving performance Explain the importance of removal A View.)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -