Tracing is the concept or process of locating errors in code/codes. It is a new feature of ASP.NET.The previous versions of ASP does not supports tracing.It was inevitable to write a few Responses.Write commands in web pages just to see what value a variable holds,or to check if a particular method or event is called or fired.The tracing feature of ASP.NET saves us the trouble of writing these outputs statements.It handles most of these automatically.
TRACING IN ASP.NET IS PROVIDED IN TWO LEVELS
- Page-Level Tracing
- Application-Level Tracing
Page-Level Tracing:
To enable page level debugging for a page,the following page directive has to be included at the beginning of the page code
%Page Trace = "true" TraceMode ="SortByCategory"%
The page directive for trace takes a parameter called TraceMode.This property can take either of the two attributes available,the SortByCategory or the SortByTime.This property determines how the information displayed at the end of the page is categoriesed.ASP.NET evena lists at what time(in seconds from the time the request begins) each event were fired for the entire life cycle of the web pages. The trace statements can either be sorted by time or by categories.The default value of this property however is SortByTime.
Application-Level Tracing:
Application level tracing by default turns on page-level tracing for all pages in the application.However,for an individual page it is possible to explicitly turn off page tracing.Application level tracing additionally provides information about the application state,contents of the session.These statics can b collected for a specified number of request as determined by the application configuration file.Enabling application level tracing is also very simple.To enable application level tracing the following line of code needs to be added to the “system.web” session of the “web.config” file.
trace enabled ="true" pageOutput="true"
The pageOutput parameter is required to set to be true.If the pageOutput statistics are supposed to be sent to the client(displaying as page level tracing).By default,this value is false.