Hi i am trying to view the event logs in the remote computer using c# . I only want to get logs with Source Enterprise Library Logging. The code below works fine in local machine. To connect to the remote machine i need to impersonate or provide some credentials that will get the code to be authenticated with remote server. How can i do the impersonation here :
var log = new EventLog("Application", "hostname", "Enterprise Library Logging");
var entries = log.Entries.OfType<EventLogEntry>().Where(o => o.Source == "Enterprise Library Logging");
Console.WriteLine("Total Entries: " + log.Entries.Count);
EventLogEntry last = log.Entries[log.Entries.Count - 1];
Console.WriteLine("Index: " + last.Index);
Console.WriteLine("Index: " + last.EntryType);
Console.WriteLine("Index: " + last.TimeWritten);