Interview Preparation mode beta
Funny Facebook Status Funny Facebook Status
Enter your email address

Can you explain the concept of trace listener?

Nice?Vote!
asked 1 year ago in .NET Interview Questions and Answers by KrishnaMachiraju (7,980 points)

1 Answer

Nice?Vote!
‘Tracelistener’ are objects that get tracing information from the trace class and they output the data to some medium. For instance you can see from the figure ‘TraceListener’ how it listens to the trace object and outputs the same to UI, File or a windows event log. There are three different types of ‘tracelistener’ first is the ‘defaulttracelistener’ (this outputs the data to UI), second is ‘textwritertracelistener’ (this outputs to a file) and the final one is ‘Eventlogtracelistener’ which outputs the same to a windows event log.

Below is a code snippet for ‘textwritertracelistener’ and ‘eventlogtracelistener’. Using ‘textwritertracelistener’ we have forwarded the trace’s to ‘ErrorLog.txt’ file and in the second snippet we have used the ‘Eventlogtracelistener’ to forward the trace’s to windows event log.
answered 1 year ago by KrishnaMachiraju (7,980 points)

Related questions