Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EventLog - Get available logs

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.

like image 724
jdecuyper Avatar asked Oct 21 '11 18:10

jdecuyper


People also ask

How do I view PowerShell logs?

PowerShell logs can be viewed using the Windows Event Viewer. The event log is located in the Application and Services Logs group and is named PowerShellCore .

Which log is available in Event Viewer?

To view the security log Open Event Viewer. In the console tree, expand Windows Logs, and then click Security. The results pane lists individual security events. If you want to see more details about a specific event, in the results pane, click the event.

Is get-EventLog deprecated?

If you are working only with the Application, System, and Security logs, then Get-EventLog may still work for you, but as a deprecated API there's no guarantee Microsoft will continue to make Get-EventLog available in the future.


1 Answers

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
            }  
        }
like image 146
KreepN Avatar answered Oct 16 '22 16:10

KreepN