Can trace be turned on/off after it's deployed to Production?

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

Guest

Hello,
I have a question about trace as MSDN seems confuses me.(http://msdn.microsoft.com/library/d...tml/frlrfSystemDiagnosticsTraceClassTopic.asp).

My answer to my question is NO, as it's decided at compile time.

Basically, from what I understand is if you define the Trace tag(by default it is defined in Release build) and you build the project( in release build), those lines containing the Trace related statements are built into your binary. So when you run the release builds, those lines will always be hit.

But MSDN says, 'Trace is enabled in both release builds and debug builds. This allows an end user to turn on tracing to help identifiy the problem without the program having to be recompiled.

I just don't understand turn on here, to me whether the Trace line is hit or not is determined at the compile time(not the run time), the end user have NO choice to turn it on or off. That is it's always ON in release build(by default).

Am I wrong?

Thanks,

Jazz
 
There are two sides to tracing. One is the TRACE conditional, which is a
compiler #define and is specific to the project. I always suggest leaving
that on (as opposed to the DEBUG one). What MSDN is saying is that even if
you switch from debug to release builds and viceversa, TRACE is always
turned on by default.

The second part is determined by both your code and the application
configuration. See the link below for a sorta detailed walkthrough.

http://www.vbbox.com/blog/2004/05/custom-trace-listeners.html


--
Klaus H. Probst, MVP
http://www.vbbox.com/


Jazz said:
Hello,
I have a question about trace as MSDN seems confuses me.(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfSystemDiagnosticsTraceClassTopic.asp).

My answer to my question is NO, as it's decided at compile time.

Basically, from what I understand is if you define the Trace tag(by
default it is defined in Release build) and you build the project( in
release build), those lines containing the Trace related statements are
built into your binary. So when you run the release builds, those lines will
always be hit.
But MSDN says, 'Trace is enabled in both release builds and debug builds.
This allows an end user to turn on tracing to help identifiy the problem
without the program having to be recompiled.
I just don't understand turn on here, to me whether the Trace line is hit
or not is determined at the compile time(not the run time), the end user
have NO choice to turn it on or off. That is it's always ON in release
build(by default).
 
probably dont need this now Klaus has posted that excellent link. Since I
went to the trouble of looking for it ...here it is anyway
http://msdn.microsoft.com/library/d.../en-us/cpgenref/html/gngrfswitcheselement.asp

--


Br,
Mark Broadbent
mcdba , mcse+i
=============
Jazz said:
Hello,
I have a question about trace as MSDN seems confuses me.(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfSystemDiagnosticsTraceClassTopic.asp).

My answer to my question is NO, as it's decided at compile time.

Basically, from what I understand is if you define the Trace tag(by
default it is defined in Release build) and you build the project( in
release build), those lines containing the Trace related statements are
built into your binary. So when you run the release builds, those lines will
always be hit.
But MSDN says, 'Trace is enabled in both release builds and debug builds.
This allows an end user to turn on tracing to help identifiy the problem
without the program having to be recompiled.
I just don't understand turn on here, to me whether the Trace line is hit
or not is determined at the compile time(not the run time), the end user
have NO choice to turn it on or off. That is it's always ON in release
build(by default).
 
Jazz said:
Hello,
I have a question about trace as MSDN seems confuses
me.(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfSystemDiagnosticsTraceClassTopic.asp).

My answer to my question is NO, as it's decided at compile time.

If you're looking for a kind of enterprise tracing solution, you might want
to investigate the logging application block:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/Logging.asp?frame=true

It is based on top of the Enterprise Instrumentation Framework.

--
Reginald Blue
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone."
- Bjarne Stroustrup (originator of C++) [quoted at the 2003
International Conference on Intelligent User Interfaces]
 
Jazz said:
Hello,
I have a question about trace as MSDN seems confuses me.(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfSystemDiagnosticsTraceClassTopic.asp).

My answer to my question is NO, as it's decided at compile time.

Basically, from what I understand is if you define the Trace tag(by
default it is defined in Release build) and you build the project( in
release build), those lines containing the Trace related statements are
built into your binary. So when you run the release builds, those lines will
always be hit.
But MSDN says, 'Trace is enabled in both release builds and debug builds.
This allows an end user to turn on tracing to help identifiy the problem
without the program having to be recompiled.
I just don't understand turn on here, to me whether the Trace line is hit
or not is determined at the compile time(not the run time), the end user
have NO choice to turn it on or off. That is it's always ON in release
build(by default).
By "turn on tracing" they mean "add a tracelistener". TRACE is defined by
default which means that the Trace lines will be in the code but, they don't
do much if no one is listening.

You should also look at TraceSwitch and BooleanSwitch and Trace.WriteLineIf
so that you can have various levels of tracing all compiled into your
production code and controlled at runtime via the app config file (or other
means).
 

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