views:

46

answers:

1

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 ?

+1  A: 

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.

Stephen Cleary
I have configured a folder to have full control for Asp.Net machine account, now the file is created, but it is empty and does not contain any trace output. I have Trace="True" on my page and I can see the tracing output on my page in the browser.
Puneet Dudeja
Did you make `autoflush` `true` as leppie suggested?
Stephen Cleary
Yes, after making autoflush="true", the trace output is coming in the target file, but from the line: HttpContext.Current.Trace.Write(sID + " tracing id"); not from the System.Diagnostics.Trace. And if I remove the writeToDiagnosticsTrace="true" attribute from System.Web configSection then HttpContext trace also not works which is obvious.
Puneet Dudeja
You do have the `TRACE` symbol defined in your build, right?
Stephen Cleary
The trace symbol must be defined, if it is not defined than the tracing output from the HttpContext.Current.Trace would also not have been written to the file.
Puneet Dudeja
I believe this has all the information you need: http://msdn.microsoft.com/en-us/library/b0ectfxd.aspx
Stephen Cleary