What is the problem with using Trace.Writeline("My Text.")

Apexprim8

Member
Joined
Oct 6, 2005
Messages
18
Location
Cheshire, United Kingdom
Programming Experience
Beginner
Hello all -

Can someone please advise what the best practice would be for implement traces in my code?

I currently just put:

VB.NET:
Trace.WriteLine((Date.Now) & ": " & System.Reflection.MethodBase.GetCurrentMethod.ToString())

in all my methods that I want to monitor. However I get a feeling this trace logging is slowing my machine down. Would this be correct? I use no threads at the moment in my application either.

Thanks for any help.

Ape
 
Note that Trace is executed in a Release version of your application too. If you just want to see what's happening while debugging then you would normally use Debug.WriteLine instead. If you want to attach trace listeners to a Release version then you'll need to use Trace, or if the value you're writing needs to be calculated in a Release version too. For instance, if you want to know how many records a query returns while debugging you could do this:
VB.NET:
Trace.WriteLine(myDataAdapter.Fill(myDataTable) & " records retrieved.")
This will not affect run time performance significantly unless you have VERY large number of such calls.
 
It's running quite slowly on the debug and release when i attach the above text to most methods. Even when I do it using a new thread for each trace.writeline it still runs agonisingly slowly. I guess this isn't practical for most applications? Spose I should use debug.writeline like you say. Cheers...
 
Back
Top