tracing 1. contents why tracing why tracing tracing in asp.net tracing in asp.net page level tracing...

28
Tracing 1 www.tech.findforinfo.com

Upload: octavia-gallagher

Post on 01-Jan-2016

235 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 1

Tracing

Page 2: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 2

Contents

Why Tracing Tracing in ASP.NET Page Level tracing Application Level tracing Tracing options Trace Output

Page 3: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 3

Debugging in Traditional ASP

ONE OF THE MOST COMMON WAYS to debug

traditional ASP web applications is to use trusty

calls to Response.Write.

This approach had several drawbacks.

When you are finished debugging your web

application using calls to Response.Write, you are

then faced with the daunting task of stripping out

all this debug code.

Page 4: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 4

Debugging in Traditional ASP

Same type of code is used both for

debugging and valid

out(Response.Write)

When your ASP pages get to be

hundreds of lines long, this can be a

real pain.

Page 5: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 5

Tracing in ASP.NET

To address this issue,ASP.NET implements the TraceContext class.

Page 6: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 6

Configuration

To use tracing in your ASP.NET web application, you need to enable it.This can be done at either The page level

(or) The application level.

Page 7: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 7

Page-Level Configuration

Enabling tracing at the page level entails adding the Trace attribute to the @Page

directive, like this:

If the Trace attribute has a value of true, tracing information will be displayed at the bottom of your ASP.NET page after the entire page has been rendered.

<%@ Page Language=”C#” Trace=”true” %>

Page 8: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 8

Application-Level Configuration

Several tracing options are available at the application level.

These settings are specified using the <trace> XML element in the system.web> section of the web.config file.

Page 9: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 9

Example of Application Level tracing

<configuration>

<system.web>

<trace enabled=”true” pageOutput=”false” requestLimit=”20”

traceMode=”SortByTime” localOnly=”true” />

</system.web>

</configuration>

Page 10: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 10

Trace Tag attributes

Attributes DescriptionrequestLimit Sets the no:of trace requests to

store on the server,Default :10Tracemode SortByTime,SortByCategory

PageOutput Sets whether the trace information is to be displayed at the bottom of every page

Page 11: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 11

Trace Tag attributes

Attributes DescriptionEnabled Set when the application level

tracing is enableLocalonly Set whether tracing is enabled

for localhost user

Page 12: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 12

page-level configuration settings overrule application-

level settings.

if tracing is disabled at the application level but is enabled at the page level,

trace information will still be displayed in the browser.

Page 13: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 13

Trace output

Now that you’ve heard so much about configuring ASP.NET tracing, what exactly

does it provide? Essentially, the trace output

generated by the TraceContext object and displayed at the bottom of your rendered ASP.NET page contains several sections.

Page 14: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 14

Request Details

Page 15: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 15

Request Details

Page 16: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 16

Trace Information

Page 17: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 17

Trace information

The Trace Information section contains the various trace

messages and warnings that both you and the ASP.NET

engine add to the trace output.

By default, the ASP.NET engine adds messages for when

any events begin or end, as with PreRender.

The order in which the contents of the Trace Information

section appear is determined by either the TraceMode

attribute

Page 18: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 18

Control tree

Page 19: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 19

Cookies collection

Page 20: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 20

Cookies Collection

The Cookies Collection section lists all the cookies that are associated with your

ASP.NET web application.

Page 21: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 21

Headers collection (Http Headers)

Page 22: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 22

Form Collection

Page 23: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 23

Form Collection

The Form Collection section is displayed

only if your ASP.NET page includes a web

form.

First, it displays the page’s VIEWSTATE.

Below the VIEWSTATE item is a listing of

each control in the Form Collection

section, along with its value.

Page 24: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 24

Querystring collection

Page 25: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 25

The Querystring Collection section is displayed only if your ASP.NET page has

Querystring parameters passed to it.

Page 26: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 26

Server variable

Page 27: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 27

Figure 6.11 Viewing a trace message with a category and

exception information in the trace output.<%@ Page Language=”C#” Trace=”true” %><script language=”C#” runat=”server”>protected void Page_Load(object Sender, EventArgs e){int x = 1;int y = 0;try{int z = x / y;}catch(DivideByZeroException ex){Trace.Write(“Errors”,”Testing the limits of infinity?”,ex);}}</script>

Page 28: Tracing 1. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application

www.tech.findforinfo.com 28

Custom trace messages