Home All Groups Group Topic Archive Search About

Seperating Debug and Trace Output

Author
8 Jul 2009 11:13 PM
Stewart Berman
I want to write trace out to a file instead of the default.  If I define a trace listener and add it
to the tracelisteners collection the debug output goes there as well.

I tried:
Private myTextWriterTraceListener As TextWriterTraceListener
myTextWriterTraceListener = New TextWriterTraceListener(System.IO.File.CreateText(Trace.txt")
and then
replaced
            Trace.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name)
            Trace.Flush()
            Trace.Indent()
with
            my.TextWriterTraceListener.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name)
            myTextWriterTraceListener.Flush()
            myTextWriterTraceListener.Indent()
but the last statement won't compile as Indent is not a method of the TextWriterTraceListener class.

Is there someone to use the Trace class without sharing listeners with the Debug class or do I have
to write a custom class to wrap the TextWriterTraceListener class and add an Indent method?

Author
9 Jul 2009 10:58 AM
Jie Wang [MSFT]
Hi Stewart,

The Trace class and the Debug class internally call a class named
TraceInternal which actually does the real work. So there is no way to stop
Trace and Debug from sharing the same set of listeners.

For the Indent method, you can use the IndentLevel property on the
TraceListener instead. The value of the property is an integer indicating
the number of times that the indent specified by the IndentSize property is
applied.

Hope this helps.

Regards,

Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd***@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Are all your drivers up to date? click for free checkup

Author
9 Jul 2009 7:38 PM
Stewart Berman
What is the difference between using <SharedListeners> or <Trace> in the application configuration
to define a trace listener?

jie***@online.microsoft.com ("Jie Wang [MSFT]") wrote:

Show quoteHide quote
>Hi Stewart,
>
>The Trace class and the Debug class internally call a class named
>TraceInternal which actually does the real work. So there is no way to stop
>Trace and Debug from sharing the same set of listeners.
>
>For the Indent method, you can use the IndentLevel property on the
>TraceListener instead. The value of the property is an integer indicating
>the number of times that the indent specified by the IndentSize property is
>applied.
>
>Hope this helps.
>
>Regards,
>
>Jie Wang
>
>Microsoft Online Community Support
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>msd***@microsoft.com.
>
>==================================================
>Get notification to my posts through email? Please refer to
>http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
>
>Note: MSDN Managed Newsgroup support offering is for non-urgent issues
>where an initial response from the community or a Microsoft Support
>Engineer within 2 business days is acceptable. Please note that each follow
>up response may take approximately 2 business days as the support
>professional working with you may need further investigation to reach the
>most efficient resolution. The offering is not appropriate for situations
>that require urgent, real-time or phone-based interactions. Issues of this
>nature are best handled working with a dedicated Microsoft Support Engineer
>by contacting Microsoft Customer Support Services (CSS) at
>http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
>==================================================
>This posting is provided "AS IS" with no warranties, and confers no rights.

Bookmark and Share