Solved

Debugging with Trace.WriteLine

Posted on 2006-07-14
6
217 Views
Last Modified: 2008-01-09
I'd like to debug a web page using Debug.WriteLine or Trace.WriteLine. Where do they output to? What should be added to web.config and the .aspx file? How should Visual Studio 2005 be configured?

My Default.aspx.cs is now

    protected void Page_Load(object sender, EventArgs e)
    {
        System.Diagnostics.Trace.Write("Hello World!");
        System.Diagnostics.Debug.Write("Hello World!");
    }

After running Default.aspx on the integrated web server nothing is seen in the Output window except the build info.
0
Comment
Question by:pallosp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
skvikram earned 300 total points
ID: 17110484
To enable tracing for the single page
<%@ Page Trace="True" %>

It will show the trace message in browser window. within lots of other trace messages.

To enable application level tracing add the following in Web.config
<system.web>
  <trace
    enabled="true"
    requestLimit="50"
    pageOutput="false"
    traceMode="SortByTime"
    localOnly="true" />
  </system.web>

To enable application level Debugging add the following in Web.config
<system.web>
  <compilation debug="true" />
  </system.web>

0
 
LVL 9

Author Comment

by:pallosp
ID: 17114052
Tre trace messages appeared, but "Hello World!" wasn't among them. The output window is still unchanged.
0
 
LVL 2

Assisted Solution

by:tempor2001
tempor2001 earned 200 total points
ID: 17117639
no need to write
System.Diagnostics.Trace.Write("Hello World!");
just use
Trace.Write ("Hello World!");
(plus enable tracing as it described skvikram in previous post)
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 9

Author Comment

by:pallosp
ID: 17117843
OK, I can see the text under the web page, but still nothing appears in the Output window. Setting pageOutput="true" doesn't help. Which Trace class is integrated with Visual Studio?
0
 
LVL 7

Expert Comment

by:skvikram
ID: 17120180
Setting pageOutput="true" doesn't help >> Setting pageOutput="true" appends trace messages to each page of aplication

Tracing is essentially a mechanism to monitor the performance of an Application.

Application-level tracing can be performed by enabling the same in web.config or machine.config file. A special page Trace.Axd is used to view trace information collected from all the pages in the application.

ASP.NET application executes in a seperate process aspnet_wp.exe . Perfmon tool can be used to monitor the performance of application.
0
 
LVL 9

Author Comment

by:pallosp
ID: 17120741
Do I think well that VS integrated trace/debug output is only supported by simple C# projects, and in ASP.NET projects I have to be satisfied with Trace.axd?
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question