Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send the tracing output to a file in the file system?

I have added the following code to my web.config file:

<system.diagnostics>
    <trace autoflush="false" indentsize="4" >
      <listeners>
        <add name="myListener"
          type="System.Diagnostics.TextWriterTraceListener"
          initializeData="d:\debugging.txt" />
        <remove name="Default"></remove>
      </listeners>
    </trace>
  </system.diagnostics>

And I have written this line for sending trace output:

System.Diagnostics.Trace.Write(sID + " tracing id");

But, I can not see any "debugging.txt" file created on my d: drive and there is no trace output.

Am I missing something ?

like image 915
teenup Avatar asked Jul 19 '10 09:07

teenup


People also ask

What is tracing output?

Most trace sources generate packetized data that might be further formatted by the trace infrastructure. This means that the captured trace data is not in a human-readable format. The trace data must go through extraction, decompression, decode, and processing stages to become human-readable.

Where is the output of a trace WriteLine?

Look at the "Output" Tab ( View | Output , or Ctrl + Alt + O ) in Visual Studio. If it's not outputting there, you need to add a listener. Check this documentation. Note: For most projects the compiler flag TRACE should be on by default in Visual Studio.

Where does system diagnostics trace WriteLine write to?

WriteLine(String) Writes a message to the trace listeners in the Listeners collection.


1 Answers

You need to trace to a directory that the ASP.NET service has write permission on.

What I like to do is just leave the default listener and run TechNet DebugView, which has the option of saving or logging to a file.

like image 99
Stephen Cleary Avatar answered Oct 24 '22 09:10

Stephen Cleary