10

Using the following code, I'm able to display all entries listed under the "Application" log:

EventLog appLog = new EventLog();
appLog.Log = "Application";
appLog.MachineName = ".";  

foreach (EventLogEntry entry in appLog.Entries)
{
 // process
}  

Since I have no FTP o RDP access to the server, is there any way to get a list of all available logs, beside "Application"? Some logs are standard but new ones can be added by users/applications.

Yahia
  • 69,653
  • 9
  • 115
  • 144
jdecuyper
  • 3,934
  • 9
  • 39
  • 51

2 Answers2

10

Run:

var d = EventLog.GetEventLogs();
        foreach(EventLog l in d)
        {
            Console.WriteLine(l.LogDisplayName);
        }

If you want to see all the names. They are stored in an array.

EDIT: To do work the way you have it set up use:

var d = EventLog.GetEventLogs();
        foreach(EventLog l in d)
        {
            foreach (EventLogEntry entry in l.Entries)
            {
                // process
            }  
        }
KreepN
  • 8,528
  • 1
  • 40
  • 58
5

Yes - use the static method EventLog.GetEventLogs... BEWARE that this needs appropriate permissions... for details and sample code see http://msdn.microsoft.com/en-us/library/ht0k516y.aspx

Yahia
  • 69,653
  • 9
  • 115
  • 144
  • Is there is any way to get windows event log for a specific source and time like WindowsLog/System last 12 hr like filter present in event viewer with System.Diagnostics.EventLog.GetEventLoges(MachineName); – Thrainder Mar 25 '20 at 10:44