Trace class

  • Thread starter Thread starter martin
  • Start date Start date
M

martin

Hi,

The trace class seems to me to be very usefull however there are a few
features of it that have to confused.
I am using visual studio 2003.

the IDE will not let me write

trace.assert(..) or trace.writeLine(..) or trace.writeif(..)

but it will let me write
debug.assert(..) or debug.writeLine(..) or debug.writeif(..)

it is as if it does recognise these methods of the trace class.

I was also interested to note that I can use trace.write(..), trace.warn(..)
without importing system.diagnostics
however I must import system.diagnostics to use debug.assert(..) ,
debug.writeline(..)

maybe I need to employ trace listeners to use these methods of the trace
class???

I am a little confused and would appreciate somebody clearing this up for
me.

cheers

martin.
 
You may have confused the two Trace classes.. one's specific to web
applications, and the other comes from System.Diagnostics as you already
noted...

That might be the explanation...
 
Thanks for that Rad,

you are indeed correct I was confusing the two. because if i write
System.Diagnostics.Trace.Write("System.Diagnostics.Trace.Write") then I can
see this being written to the output window.

the trace I was original refering too belongs to TraceContext Class

this brings up an interesting point.

if I have the follwoing defined in an asp dotnet application that is built
for debug
Debug.Assert(True, "From Assert -- True")
Debug.WriteIf(True, "Message written by debug.WriteIf" & vbCrLf)
Trace.Warn("Page_Load", "Finished Page_Load")

System.Diagnostics.Trace.WriteLine("System.Diagnostics.Trace.WriteLine" &
vbCrLf)
System.Diagnostics.Trace.Write("System.Diagnostics.Trace.Write" &
vbCrLf)

then when it is run in the debugger the trace information can be seen in the
output window.
I keep reading stuff that says when the application is complied for release
the debug stuff is taken out but trace stuff is left in.

This seems odd as the only place that I can see the trace stuff is in the
debugger, so if its a non debug version I' knid of stuck.

I was hoping that I could leave the trace stuff in my application when it
was compiled for realease and simple turn tracing on or off in web.config,
and then I would be able to see any of the system.diagnostics.trace out put
either at the bottom of the web page ot in trace.axd, but this appears not
to be the case.
I am missing something here.
is the <trace> element in web.config only connected to the TraceContext
Class and has nothing to do with the system.diagnostics.trace class.

many thanks for any advice that can be offered.

cheers

martin.
 
It'd be best to read up on tracing in asp.net -- it's a separate "topic."
There's more info and some of the confusion you mentioned below will clear
up. I'm afraid you're still mixing them up to a certain degree. more or
less, there's no need to use System.Diagnostics.Trace in a web app.. just
use Trace...

you can then either check up trace.axd or simply turn on trace=true in the
@Page directive.. and see the output on the page right away..
 
Back
Top