473,783 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5267
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*******@disc ussions.microso ft.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 DefaultTraceLis tener the messages will be reported through
the Win32 OutputDebugStri ng 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.b et 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
1434
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() includes: TextWriterTraceListener fw = new TextWriterTraceListener(myFile); TextWriterTraceListener sw = new TextWriterTraceListener(Console.Out); Trace.Listeners.Add(fw); Trace.Listeners.Add(sw);
10
4897
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 which produce the same result: Dim dt As System.Data.DataTable Dim dt As DataTable = New DataTable The error message reads: System.NullReferenceException: Object reference
4
718
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
18797
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 2003 The sample in the help file does not work. I tried now for days ... Pls could anybody post a sample, including necessary imports and so on -
6
4120
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 make it work in Release build? Bill
3
2871
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 like what MFC's TRACE macro does (during debugging). Could you please share your knowledge with me? Thanks in advance.
3
2960
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 strConnection = "Server1"; if the code was compiled in release: string strConnection = "Server2"; Thanks!
2
7213
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 define/undefine DEBUG and TRACE compiler definitions, I still get the messages in the Output window. What might be the problem? Thanks Bob
2
9039
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 figure this problem out. Any suggestions? thanks Joel
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.