You have the following code (line numbers are included for reference only):
You need to ensure that if an exception occurs, the exception will be logged.
Which code should you insert at line 28?

A.
Option A
B.
Option B
C.
Option C
D.
Option D
Explanation:
* XmlWriterTraceListener
Directs tracing or debugging output as XML-encoded data to a TextWriter or to a Stream, such as a
FileStream.
* TraceListener.TraceEvent Method (TraceEventCache, String, TraceEventType, Int32)
Writes trace and event information to the listener specific output.
Syntax:
[ComVisibleAttribute(false)]
public virtual void TraceEvent(
TraceEventCache eventCache,
string source,
TraceEventType eventType,
int id
)
C
1
0
I think B is correct. Altough C produces also a valid XML. I tested all answers with following results:
Answer A – nonsens
Answer B – correct output file
Answer C – produces output file with –> seems weird
Answer D – The parameter for the TraceSource constructor is the NAME of the trace source –> no output file produced –> nonsens
second param in log1.TraceEvent is the source name! Not really wise to put ex.message there…
0
0
Answer B is correct.
Answer C works but it is wrong because the the second parameter is source, not message. It produces wrong XML
0
0