title: Writing to event log by using data from config file
body: <p>I am doing some practice tests for Microsoft's "Programming in C#" exam 70-483 and one of the questions has me in a stump and I don't know enough about tracing to test it properly.</p>
  
  <p>The question is this:</p>
  
  <p>You are developing an application that uses a .config file.
  <br/>The relevant portion of the .config file is shown as follows:</p>
  
  <pre><code>   &lt;system.diagnostics&gt;
        &lt;trace autoflush="false" indentsize="0"&gt;
           &lt;listeners&gt;
              &lt;add name="appListener"
                 type="System.Diagnostics.EventLogTraceListener"
                 initializeData="TraceListenerLog" /&gt;
           &lt;/listeners&gt;
        &lt;/trace&gt;
     &lt;/system.diagnostics&gt;
  </code></pre>
  
  <p>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?</p>
  
  <p>A. <code>EventLog log = new EventLog();
  &lt;br/&gt;log.WriteEntry("Trace data...");</code></p>
  
  <p>B. <code>Debug.WriteLine("Trace data...");</code></p>
  
  <p>C. <code>Console.SetOut(new StreamWriter("System.Diagnostics.EventLogTraceListener")); &lt;br/&gt;Console.WriteLine("Trace data...");</code></p>
  
  <p>D. <code>Trace.WriteLine("Trace data...");</code>                         </p>
  
  <p>I'm thinking "C" because it's the only option that has <em>something</em> to do with the .config file, but it says the correct answer is "D" for some reason. Mind you these questions have been wrong before about completely simple and obvious stuff, so...</p>
  
  <p>Can you please explain which is the correct answer and why?</p>