From: Tony Johansson on 6 May 2010 11:56 Hi! This example was found in a book. It will write the text "This is my test" to the output that can be found under the View menu alternative. Trace.Listeners.Clear(); DefaultTraceListener myListener = new DefaultTraceListener(); Trace.Listeners.Add(myListener); System.Diagnostics.Debugger.Log(1, "Test", "This is my test"); I made a little test here so I removed all rows and kept just this one System.Diagnostics.Debugger.Log(1, "Test", "This is my test"); and I get the same result. Does the Debugger has a Listener by default ? //Tony
From: Alberto Poblacion on 6 May 2010 12:23 "Tony Johansson" <johansson.andersson(a)telia.com> wrote in message news:uCvT%23ST7KHA.420(a)TK2MSFTNGP02.phx.gbl... > This example was found in a book. It will write the text "This is my test" > to the output that can be found under the View menu alternative. > Trace.Listeners.Clear(); > DefaultTraceListener myListener = new DefaultTraceListener(); > Trace.Listeners.Add(myListener); > System.Diagnostics.Debugger.Log(1, "Test", "This is my test"); > > I made a little test here so I removed all rows and kept just this one > System.Diagnostics.Debugger.Log(1, "Test", "This is my test"); > and I get the same result. > > Does the Debugger has a Listener by default ? I believe that you are mistaking the System.Diagnostics.Debugger class for the System.Diagnostics.Debug class. The former has a "Log" method that posts a message to the attached debugger (and does not use the TraceListener). The latter has a "Write" method that *does* use the TraceListener.
From: Jeff Johnson on 6 May 2010 12:24 "Tony Johansson" <johansson.andersson(a)telia.com> wrote in message news:uCvT%23ST7KHA.420(a)TK2MSFTNGP02.phx.gbl... > This example was found in a book. It will write the text "This is my test" > to the output that can be found under the View menu alternative. > Trace.Listeners.Clear(); > DefaultTraceListener myListener = new DefaultTraceListener(); > Trace.Listeners.Add(myListener); > System.Diagnostics.Debugger.Log(1, "Test", "This is my test"); > > I made a little test here so I removed all rows and kept just this one > System.Diagnostics.Debugger.Log(1, "Test", "This is my test"); > and I get the same result. > > Does the Debugger has a Listener by default ? The Debugger doesn't have listeners at all; the Trace class does. From MSDN (Trace.Listeners property): ============= The listeners produce formatted output from the trace output. By default, the collection contains an instance of the DefaultTraceListener class. =============
|
Pages: 1 Prev: OOP issue: should I pass an object or an object property? Next: Create and sort on XML File |