2

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);
John Saunders
  • 160,644
  • 26
  • 247
  • 397
nzdev
  • 324
  • 1
  • 9
  • 24
  • What version of .NET are you using? – John Saunders Apr 17 '13 at 01:16
  • possible duplicate of [EventLogQuery reader for remote computer?](http://stackoverflow.com/questions/7966993/eventlogquery-reader-for-remote-computer) - check here on [so] I am sure there's a few dup's for this question. eg http://stackoverflow.com/questions/914446/what-is-the-fastest-way-to-read-event-log-on-remote-machine and http://stackoverflow.com/questions/5313211/read-event-log-remotely-with-net and etc – Jeremy Thompson Apr 17 '13 at 01:24
  • its a different thing man – nzdev Apr 17 '13 at 01:28

0 Answers0