Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What’s the difference between the Debug class and Trace class? [duplicate]

I am attempting to write better error-handling and debug logic in one of our applications. Can someone explain the difference between the Debug and Trace class? The documentation looks pretty similar. I want to use these classes in conjunction with NLog to improve our debugging efforts.

like image 321
Grasshopper Avatar asked Oct 20 '12 03:10

Grasshopper


People also ask

What is the difference between trace class and debug class?

What is difference between Debug and Tracing? Debug is going through the code flow during run time where as tracing is giving details of execution plan, process timing details. Debug and trace enables you to monitor the application for errors and exception with out VS.NET IDE.

What is the difference between debug write and trace write?

Debug. Write is only effective on builds where the DEBUG flag is defined, while Trace. Write is only effective when the TRACE flag is defined.

Is trace higher than debug?

Ans. TRACE designates finer grained informational events than the DEBUG. TRACE is level lower than DEBUG.

What is the use of trace class?

Tracing helps you isolate problems and fix them without disturbing a running system. This class provides methods to display an Assert dialog box, and to emit an assertion that will always Fail. This class provides write methods in the following variations: Write.


2 Answers

The Debug and Trace classes have very similar methods. The primary difference is that calls to the Debug class are typically only included in Debug build and Trace are included in all builds (Debug and Release). You can control this through the compiler flags DEBUG and TRACE. If you look at the documentation for both, you will notice the ConditionalAttribute annotating the methods. This causes the method calls to be included in the binaries only when the appropriate compiler flag is defined. You could define your own compiler flag and use it in conjunction with the ConditionalAttribute in a similar fashion. Note that if you use this, the methods are not removed from the compiled binaries. The call sites are modified to remove the method calls.

like image 103
Mike Zboray Avatar answered Oct 06 '22 00:10

Mike Zboray


Debug is used during debugging. Trace is writing to the log file. It is kind of like logging. Both are very similar, but do tracing for long term retention, debugging for real time debugging.

like image 44
iefpw Avatar answered Oct 06 '22 00:10

iefpw