title: Writing to event log in C# - do I need to use EventLog.CreateEventSource when writing to Application log?
body: <p>When I use the following code to write to Application Event log, everything works fine:</p>
  
  <pre><code>EventLog log = new EventLog();
  log.Source = "Application";
  log.WriteEntry("test message", EventLogEntryType.Error);
  </code></pre>
  
  <p>When I use the code that is from MSDN and all other blogs, I get the security error (I am guessing because CreateEventSource raises it).</p>
  
  <pre><code>string sSource = "MyWebService";
  string sLog = "myApplication";
  string sMsg = errorMessage;
  
  if (!EventLog.SourceExists(sSource))
     EventLog.CreateEventSource(sSource, sLog);
  
   EventLog.WriteEntry(sSource, sMsg, EventLogEntryType.Error);  
  </code></pre>
  
  <p>So, do I need to check whether the source exists if all I need is to write to Application log which is there by default? </p>
  
  <p>What is the proper way to write to EventViewer? </p>