title: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security
body: <p>I am getting error:</p>
  
  <blockquote>
    <p>The source was not found, but some or all event logs could not be
    searched. Inaccessible logs: Security</p>
  </blockquote>
  
  <p>When I run below code to capture errors on Win 2K12 R2 server IIS 8.5</p>
  
  <pre><code>EventLog elog = new EventLog();
  EventLog.CreateEventSource("MyApp", "Application");
  EventLog.WriteEntry(Source, swError.ToString(), EventLogEntryType.Error);
  </code></pre>
  
  <p>I've given full access to <code>HKLM\SYSTEM\CurrentControlSet\services\eventlog</code> but it is not working still. What shall I do to fix it?</p>