Arjun
Arjun

Reputation: 1069

how to read trace

I have a snipnet which writes user name to trace.

Trace.WriteLine("Current User: " + userIdentity.Name);

How to read this information. I did good search in net, no luck. Can we read default trace?

Thank in advance.

Upvotes: 1

Views: 4099

Answers (1)

Nahum
Nahum

Reputation: 7197

the default trace listener writes into Console. you can see its output in the debugger using CTRL+W ,O (View->Output)

you need a proper Trace listener http://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener.aspx

when you use Trace.WriteLine() all the trace listeners catch this and write

my personal favorite is XmlWriterTraceListener

just do like this

Trace.Listener.Add(new XmlTraceListener (tracefilepath));

use Trace.WriteLine() and watch how it creates a nice xml file that can be easily viewed using Service Trace Viewer Tool (SvcTraceViewer.exe)

Upvotes: 4

Related Questions