title: Accessing Application and Service logs with C#
body: <p>I was wondering if there is a way to reach the logs under the section named Application and Service Logs in the Event viewer utility in Windows. The thing is, I can read the entries under Windows Logs with the code below. I read the whole entry, and get the items with the necessary id, getting top 20 results. But I couldn't find anything on accessing the Application and Service logs section. Should I change the LogType in the EventLog constructor? Or is there a different method or class to access Application and Service logs? Trying <code>"Application"</code> as the <code>logType</code> variable doesnt work.</p>
  
  <pre><code>        string str = "";
          EventLog ev = new EventLog(logType, System.Environment.MachineName);
          int LastLogToShow = ev.Entries.Count;
          if (LastLogToShow &lt;= 0)
              Console.WriteLine("No Event Logs in the Log :" + logType);
  
          int i;
          int k = 0;
  
          for (i = ev.Entries.Count - 1; i &gt;= 0; i--)
          {
              EventLogEntry CurrentEntry = ev.Entries[i];
              if (CurrentEntry.EventID == id)
              {
                  if (id == 1)
                  {
                      str += "Son Açılma \n";
                      str += "Olay Zamanı: " + CurrentEntry.TimeGenerated.ToLongDateString() + " " + CurrentEntry.TimeGenerated.ToShortTimeString() + "\n";
                  }
  
                  else if (id == 42)
                  {
                      str += "Son Kapatılma \n";
                      str += "Olay Zamanı: " + CurrentEntry.TimeGenerated.ToLongDateString() + " " + CurrentEntry.TimeGenerated.ToShortTimeString() + "\n";
                  }
                  else
                  {
                      str += "Event type: " + CurrentEntry.EntryType.ToString() + "\n";
                      str += "Event Message: " + CurrentEntry.Message + CurrentEntry + "\n";
                      str += "Event : " + CurrentEntry.UserName + "\n" + "\n";
                      str += "Olay Zamanı: " + CurrentEntry.TimeGenerated.ToLongDateString() + " " + CurrentEntry.TimeGenerated.ToShortTimeString() + "\n";
                  }
                  k++;
              }
              if (k &gt; 20)
                  break;
          }
          ev.Close();
          return str;
  </code></pre>
  
  <p>What I am looking for is under </p>
  
  <p>Application and Service Logs/</p>
  
  <p>Microsoft/</p>
  
  <p>Windows/</p>
  
  <p>TerminalServices-RemoteConnectionManager/</p>
  
  <p>Operational/</p>
  
  <p>Event ID 1149</p>