Re: Trace debug for every method in code
- From: kplkumar@xxxxxxxxx
- Date: 13 Mar 2006 08:59:46 -0800
Alright, this is what my suervisor wants.
For every method that is entered and exited in the sequence of
execution, I need an entry in a trace.log file. Other information such
as time it entered and exited, other methods called(in a treee
structure), and other misc information would be helpful.
So I looked at Enterprise Library 1.0 and found that I can use
something called Tracer like this.
private void button1_Click(object sender, EventArgs e)
{
using (new Tracer("Trace"))
{
method1();
// more statements
}
}
This should be done in every method, to acheive something like what I
mentioned above. This can be controlled by changed the App.config using
the EL Configuration tool.
(or)
We can do this without using EL simply by,
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine("Entering button1_Click");
// do something
System.Diagnostics.Trace.WriteLine("Exiting button1_Click");
}
____________________________________________________________
In my opinion both pose the same problem. The developer has to
explicitly put the trace statements inside every method definition.
Although the EL let's you turn on and off the trace at runtime, there
is no optimization of code while compilation. So I iwll have hundreds
of lines of these "using(Tracer....." statements compiled as part of my
deployment code. But using the "System.Diagnostics.Trace..." this can
be avoided by turning off the TRACE in the "Conditional Compilation
Constants" setting in the project properties, but this does not allow
you to turn on/off during runtime unlike the EL.
So where should I hit the middle ground??? Any suggestions.
.
- References:
- Trace debug for every method in code
- From: kplkumar
- Re: Trace debug for every method in code
- From: AlanT
- Trace debug for every method in code
- Prev by Date: Re: Unable to load DLL - The file is there
- Next by Date: Re: Getting the name of my application at runtime...
- Previous by thread: Re: Trace debug for every method in code
- Next by thread: Re: Trace debug for every method in code
- Index(es):