473,385 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to use trace?

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

Jul 21 '05 #1
8 1560
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

Jul 21 '05 #2
thanks, but i want to save the log into a database text field. how can
i do that?

Jul 21 '05 #3
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

Jul 21 '05 #4
also the trace.axd page doesn't show which methods were called.

Jul 21 '05 #5
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?

Jul 21 '05 #6
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.

Jul 21 '05 #7
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?


Jul 21 '05 #8
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

}

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ken | last post by:
I would like to start using EventLogTraceListener, and am running into a couple of significant limitations: 1) I have found that there is no way to write EventLog entries with different...
9
by: svenn.are | last post by:
Hi, has anybody thought of / already used graphviz to convert the output of trace.py into a graph? I looked at PyUMLGraph, but 1. PyUMLGraph does not successfully create a dot file, and 2. I...
2
by: Wilfried Hoermann | last post by:
Presumably a trivial question... I want to write trace information from a web service to a log file using the Trace Class. Is this possible without closing and opening the Trace in every single...
5
by: martin | last post by:
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 ...
3
by: JR | last post by:
I'm experiencing a problem where, for seemingly no reason, trace output stops being logged (and appearing on my pages.) trace.enabled suddenly just turns to false. Any idea why this happens?...
5
by: who be dat? | last post by:
Hello all. I'm writing an application that is writing trace information that can be viewed in trace.axd. I would like to rename this and use a different name specific to my application. I know...
5
by: cameron | last post by:
I have attempted to lock down the trace.axd file with the standard: <location path="trace.axd"> <system.web> <authorization> <allow roles="SOME GROUP"/> <deny users="*"/> </authorization>...
9
by: Joe Rattz | last post by:
I can't seem to get to trace.axd. I have turned tracing on in web.config. Here is how I currently have i configured: <trace enabled="true" requestLimit="10" pageOutput="false"...
1
by: Patrick | last post by:
When Tracing in ASP.NET, the IIS process (on IIs5.1) is locking on the Trace file, and I can't read the trace file without restarting the IIS: Even the following does NOT work (how could I fix...
3
by: Arman Sahakyan | last post by:
Hi, I'm an MFC programmer and know little about .NET programming. Now, for some reasons, I'm developing an ASP .NET application... What I need to know is how to output into VS's Output Window...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.