Debug and Trace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin

    #1

    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
  • Andres Taylor

    #2
    Re: Debug and Trace

    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" <anonymous@disc ussions.microso ft.com> wrote in message
    news:013e01c392 da$b32c5a20$a00 1280a@phx.gbl.. .[color=blue]
    > 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[/color]


    Comment

    • Richard Grimes [MVP]

      #3
      Re: Debug and Trace

      Kevin wrote:[color=blue]
      > 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?[/color]

      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 evpuneqt@zicf.b et is encrypted with ROT13 (www.rot13.org)


      Comment

      Working...