PrepAway - Latest Free Exam Questions & Answers

What should you include in the application code?

You are developing an application that uses a .config file.
The relevant portion of the .config file is shown as follows:

You need to ensure that diagnostic data for the application writes to the event log by using the configuration
specified in the .config file.
What should you include in the application code?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
http://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.eventlogtracelistener
public static void Main(string[] args) {
// Create a trace listener for the event log.
EventLogTraceListener myTraceListener = new EventLogTraceListener(“myEventLogSource”);
// Add the event log trace listener to the collection.
Trace.Listeners.Add(myTraceListener);
// Write output to the event log.
Trace.WriteLine(“Test output”);
}

2 Comments on “What should you include in the application code?

  1. Mario says:

    You need to ensure that diagnostic data for the application “””writes to the event log””” by using the configuration
    specified in the .config file.

    Only alternative A writes to the event log.




    0



    1
    1. petro says:

      No, answer D is actually correct.
      You can check this by adding configuration text, that is listed below, to your .config file. And then checking Trace.Listeners object – there will be 2 objects, including one from configuration -> it will write messages to EventLog with Trace.WriteLine() method. (In order to write to EventLog you need to start VisualStudio with administrator rights)




      5



      0

Leave a Reply