How to implement Trace best

  • Thread starter Thread starter Thorsten Tarrach
  • Start date Start date
T

Thorsten Tarrach

Hallo,
The best thing would be to implement a trace call in every procedure to
write an entry in the log file:
If MySwitch.TraceVerbose() then trace.writeline("Procedure xyz started with
Parameters ...")

Unfortuantelly is this a lot of work.
Is there an easier way to implement a good tracing?
How is tracing done in professional applications?
Thanks, Thorsten
 
I don't know about performance overhead issues here, but you could be more
generic by using code like:

Trace.WriteLine("Entering " + MethodBase.GetCurrentMethod().ToString () );

and there are probably Reflection methods you could call to enumerate the
parameter names and values.
 
Phil Wilson said:
I don't know about performance overhead issues here, but you could be more
generic by using code like:

Trace.WriteLine("Entering " + MethodBase.GetCurrentMethod().ToString () );

and there are probably Reflection methods you could call to enumerate the
parameter names and values.

Yes, that is a good idea, I can get all methods with the StackTrace.
Unfortunatelly is there no way to get the paramterters passed to that
method.

Next would be error tracing. Can be done the same way, but is there some
kind of event fired, when an error occurs?
Thorsten
 
Back
Top