Debug trace

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 like
what MFC's TRACE macro does (during debugging).

Could you please share your knowledge with me?

Thanks in advance.
 
Hi Arman,

Add the following configuration to the web.config file in your application's
root directory:

<configuration>
<system.web>
<trace enabled="true" />
<compilation debug="true" />
</system.web>
</configuration>

<trace... /> corresponds to Page.Trace methods.
<.. debug.. /> corresponds to System.Diagnostics.Debug methods.

Debug will write to the Visual Studio output window as you requested, but only
if debug="true".

Trace output can be viewed in two ways:

1. Request "/trace.axd" in your browser when <trace> is enabled. You'll see
the trace per request and a Details link to drill down to page-level trace.
The actual Page.Trace output is under the "Trace Information" section.

2. You can have page-level trace information appended to the end of each
requested page by making the following changes to the configuration above:

<configuration>
<system.web>
<trace enabled="true" pageOutput="true" />
</system.web>
</configuration>

3. You can have page-level trace information appended to the end of a
particular page by modifying the @ Page directive as follows:

<%@ Page ... Trace="true" ... %>

"Trace" can be added to the @ Page directive even when <trace> is not enabled
in the web.config file.

Debug="true" can also be added to the @ Page directive even when using
debug="false" in the web.config file, but you'll have to attach the debugger
after building in VS 2005 to see what's written in the output window. IIRC,
that wasn't a problem in earlier versions of VS.NET.
 
Many thanks you guys. These are what I've been wondering.


--
======
Arman



Dave Sexton said:
Hi Arman,

Add the following configuration to the web.config file in your application's
root directory:

<configuration>
<system.web>
<trace enabled="true" />
<compilation debug="true" />
</system.web>
</configuration>

<trace... /> corresponds to Page.Trace methods.
<.. debug.. /> corresponds to System.Diagnostics.Debug methods.

Debug will write to the Visual Studio output window as you requested, but only
if debug="true".

Trace output can be viewed in two ways:

1. Request "/trace.axd" in your browser when <trace> is enabled. You'll see
the trace per request and a Details link to drill down to page-level trace.
The actual Page.Trace output is under the "Trace Information" section.

2. You can have page-level trace information appended to the end of each
requested page by making the following changes to the configuration above:

<configuration>
<system.web>
<trace enabled="true" pageOutput="true" />
</system.web>
</configuration>

3. You can have page-level trace information appended to the end of a
particular page by modifying the @ Page directive as follows:

<%@ Page ... Trace="true" ... %>

"Trace" can be added to the @ Page directive even when <trace> is not enabled
in the web.config file.

Debug="true" can also be added to the @ Page directive even when using
debug="false" in the web.config file, but you'll have to attach the debugger
after building in VS 2005 to see what's written in the output window. IIRC,
that wasn't a problem in earlier versions of VS.NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top