By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,984 Members | 2,686 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,984 IT Pros & Developers. It's quick & easy.

how to use trace?

P: n/a
this is what I want to do.

i have an input box and a submit button. the input gets processed by my
program and it returns the results. depending on the input, not all the
functions in my program are called, some might be called multiple
times, the order of functions called might be different each time. I
would like to log all this, what function actually got called...

this is my plan
create a global string named TRACE
in each function add its name to trace

string processInput1(string input)
{
//process input
....

TRACE = TRACE + "processInput1";
return input
}
but this is method is clumsy. is there a builtin function in dotNet?
please show me a good example.

Thanks in Advance
Aaron

Nov 19 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Your wish is granted.

The good folks at Microsoft predicted your need eons ago.

From within your ASPX code;

Trace.Write ( whatever you want to be logged );

Place this anywhere in your code, as often as you require.

In your Web.config, look for the following section;

<trace
enabled="true"
requestLimit="100"
pageOutput="false"
traceMode="SortByTime"
localOnly="false"
/>

Make sure to set enabled to "true"; I also like to set localOnly to false
and to increase the requestLimit.

Run your page, do your testing, and then CTRL+N to open a new browser
window. Change the Url to;

http://yoursite/trace.axd
or
http://yoursite/yourvirtualdir/trace.axd
if you're using virtual directories

You'll be surprised at what you find.

/// M
"Aaron" <ku*****@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
this is what I want to do.

i have an input box and a submit button. the input gets processed by my
program and it returns the results. depending on the input, not all the
functions in my program are called, some might be called multiple
times, the order of functions called might be different each time. I
would like to log all this, what function actually got called...

this is my plan
create a global string named TRACE
in each function add its name to trace

string processInput1(string input)
{
//process input
...

TRACE = TRACE + "processInput1";
return input
}
but this is method is clumsy. is there a builtin function in dotNet?
please show me a good example.

Thanks in Advance
Aaron

Nov 19 '05 #2

P: n/a
thanks, but i want to save the log into a database text field. how can
i do that?

Nov 19 '05 #3

P: n/a
Regarding the above, I'm assuming that you're using ASP.NET, since you've
included that group in your post. If not, your approach may be slightly
different.

Also, do not include the System.Diagnostics namespace. You want to use the
Trace functionality built directly into the HttpContext.Current class,
rather than a new orphan Trace object. If you include System.Diagnostics,
your trace output will not appear in Trace.axd; rather you will have to
specify a listener.

/// M

"Aaron" <ku*****@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
this is what I want to do.

i have an input box and a submit button. the input gets processed by my
program and it returns the results. depending on the input, not all the
functions in my program are called, some might be called multiple
times, the order of functions called might be different each time. I
would like to log all this, what function actually got called...

this is my plan
create a global string named TRACE
in each function add its name to trace

string processInput1(string input)
{
//process input
...

TRACE = TRACE + "processInput1";
return input
}
but this is method is clumsy. is there a builtin function in dotNet?
please show me a good example.

Thanks in Advance
Aaron

Nov 19 '05 #4

P: n/a
Hello Aaron,

Look at the System.Diagnostics.Trace class: http://msdn.microsoft.com/library/de...classtopic.asp

--
Matt Berther
http://www.mattberther.com
this is what I want to do.

i have an input box and a submit button. the input gets processed by
my program and it returns the results. depending on the input, not all
the functions in my program are called, some might be called multiple
times, the order of functions called might be different each time. I
would like to log all this, what function actually got called...

this is my plan
create a global string named TRACE
in each function add its name to trace
string processInput1(string input)
{
//process input
...
TRACE = TRACE + "processInput1";
return input
}
but this is method is clumsy. is there a builtin function in dotNet?
please show me a good example.

Thanks in Advance
Aaron

Nov 19 '05 #5

P: n/a
also the trace.axd page doesn't show which methods were called.

Nov 19 '05 #6

P: n/a
Ah, in that case you do want to use the Trace in System.Diagnostics, and
write yourself a custom listener that outputs to your database.

I recommend Dan Appleman's eBook "Tracing and Logging with .NET"; a whopping
US$10 through Amazon. Or direct from Desaware's site;

http://www.desaware.com/products/boo...ing/index.aspx

Or do some Googling on "System.Diagnostics.Trace" or
"System.Diagnostics.Trace.Listeners.Add"; you should be able to assemble
similar best practices for using Trace, and examples for how to write your
own Listener.
"Aaron" <ku*****@yahoo.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
thanks, but i want to save the log into a database text field. how can
i do that?

Nov 19 '05 #7

P: n/a
Correct; I put a Trace.Write () at the top of my methods when I need to
track the call path.

"Aaron" <ku*****@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
also the trace.axd page doesn't show which methods were called.

Nov 19 '05 #8

P: n/a
Ah, the magic Googlecantation seems to be;

"TraceListener custom database"
"MWells" <outbound__at_sygnal.com> wrote in message
news:eE**************@TK2MSFTNGP14.phx.gbl...
Ah, in that case you do want to use the Trace in System.Diagnostics, and
write yourself a custom listener that outputs to your database.

I recommend Dan Appleman's eBook "Tracing and Logging with .NET"; a whopping US$10 through Amazon. Or direct from Desaware's site;

http://www.desaware.com/products/boo...ing/index.aspx

Or do some Googling on "System.Diagnostics.Trace" or
"System.Diagnostics.Trace.Listeners.Add"; you should be able to assemble
similar best practices for using Trace, and examples for how to write your
own Listener.
"Aaron" <ku*****@yahoo.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
thanks, but i want to save the log into a database text field. how can
i do that?


Nov 19 '05 #9

P: n/a
thanks, how do i store the trace info into a string variable? since i
already have a db connection and don't need to create a new one.

what are the benfits of using trace than the method i described?
-------------
create a global string named TRACE
in each function add its name to trace
string processInput1(string input)
{
//process input
....

TRACE = TRACE + "processInput1";
return input

}

Nov 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.