473,406 Members | 2,713 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,406 software developers and data experts.

Debug and Trace

Hi All,

Can someone please tell me what the difference is between
DEBUG and TRACE. From what I can see, they are two
different classes, but with the same members? Whats the
purpose of have two different classes that seem to do the
same thing?

Thanks alot for any help, much appreciated
Kevin
Nov 15 '05 #1
2 5241
Hi Kevin,

Debug is used to debug applications in development, while Trace can used to
log actions in production code.

HTH,

Andrés Taylor

"Kevin" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
Hi All,

Can someone please tell me what the difference is between
DEBUG and TRACE. From what I can see, they are two
different classes, but with the same members? Whats the
purpose of have two different classes that seem to do the
same thing?

Thanks alot for any help, much appreciated
Kevin

Nov 15 '05 #2
Kevin wrote:
Hi All,

Can someone please tell me what the difference is between
DEBUG and TRACE. From what I can see, they are two
different classes, but with the same members? Whats the
purpose of have two different classes that seem to do the
same thing?


The only difference is that the C# compiler will include calls to the
methods of the Trace class only if TRACE is defined, and to methods of Debug
if DEBUG is defined. The idea is that the latter (Debug) should have rich
descriptive debug messages for use only for debug builds whereas the former
(Trace) should have fewer more succinct messages for release builds.

Personally, I don't subscribe to the idea of leaving trace messages in
release builds. There are several reasons for this:

- if the trace information is important to the user, then the user should
see it in the application UI, if it is used for debugging then it should be
in the debug build only
- if you want to trace information to the event log, then call the event log
directly - even better, use some unmanaged C++ to write messages to the
event log because the EventLog class really sucks in this respect
- if Trace is meant for release builds then why isn't it allowed by default
without having to define TRACE?

Also, if you use DefaultTraceListener the messages will be reported through
the Win32 OutputDebugString and this essentially couples the trace listener
(and the .NET process) to the viewer used to read the debug strings. If the
reader is written badly and takes a long time reading each string then your
..NET application will also have this delay :-(

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)
Nov 15 '05 #3

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

Similar topics

0
by: Pete W | last post by:
I have a console application for which I have atttemped to use TextWriterTraceListener. The app uses System.Diagnostic I want to trace or debug to Console and also to file. code in Main()...
10
by: Scott | last post by:
I have a simple asp.net app which works fine in debug mode, but crashes on the following line when I run it on the production server: Dim dt As DataTable I have tried the following variations...
4
by: A.M | last post by:
Hi, If I use System.Diagnostics.Debug.WriteLine in a asp.net application, where does the output go? Is there any trace monitor application thar shows me the trace output? Thanks, Allan
7
by: Thomas Pecha | last post by:
Sorry for all who think this is easy, I was not able to handle this Coming from VB6 where with simple debug.print strAString you could write to debug window, I am totalling failing in vb.net...
6
by: swartzbill2000 | last post by:
Hello, I have a VB 2005 Express project with a TraceListener-derived class to route Debug.Print output to a log file. It works fine for Debug builds. What is the correct combination of changes to...
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...
3
by: =?Utf-8?B?ZWxhZGxh?= | last post by:
Hi. I was wondering if it was possible to give a variable different values depending on if the code was compiled in debug or release? i.e. if the code was compiled in debug: string...
2
by: Bob S | last post by:
I am using Debug.WriteLine and Trace.WriteLine to output messages from a dll. This dll is used in an application. No matter whether i run the program in release mode or debug mode and whether i...
2
by: joelkeepup | last post by:
Hi, I made a change this morning and now im getting an error that says either "a is undefined or null" or "e is undefined or null" the microsoft ajax line is below, I have no idea how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.