How can i read event logs residing at a remote computer on the same network using System.Diagnostics.EventLog in .net. it works fine if i give my own (local) computer name. But i don't know how to pass the remote computer name.
EventLog
eventLogs = new EventLog("Application","P036");p036 is local computer name. how can i access logs on computer with name p037.
Please reply as soon as someone get it.
Thanks in advance.

Niradhip ChakrabortyRank #429 · 5.8K reputationPosted May 26, 2009, 10:50 AM EDT
http://www.artima.com/forums/flat.jsp?forum=152&thread=135902
Naeem Ahmed3 reputationPosted May 28, 2009, 8:18 AM EDT
Thanks Niradhip(James Hetfield).
But it doesn't anwer my question at all. I'm using the same namespace to read eventlogs. but my question was that how to pass the name of the remote machine as MachineName in second parameter of EventLog Constructor.
EventLog eventLogs = new EventLog("LogName","Remote Machine Name");
Thanks for showing interest in the thread.
chandrasekhar ravuri20 reputationPosted Dec 2, 2009, 10:42 PM EST
machine = "1.12.45.7"
log = "LgName"
If (Not EventLog.Exists(log, machine)) Then
Console.WriteLine("The log does not exist!")
Exit Sub
End If
Dim aLog As EventLog
aLog = New EventLog
aLog.Log = log
aLog.MachineName = machine
Console.WriteLine("There are {0} entr[y|ies] in the log:", CStr(aLog.Entries.Count))
Dim entry As EventLogEntry
For Each entry In aLog.Entries
Console.WriteLine(" Entry: {0}", entry.Message)
Next entry
Console.ReadLine()
Lalit MRank #1,186 · 1.5K reputationPosted Dec 2, 2009, 11:02 PM EST
i find code fore read/write event log of local computer and remote computer,you can also this code sample
/logType can be Application, Security, System or any other Custom Log. string logType = "Application"; EventLog ev = new EventLog(logType, System.Environment.MachineName); int LastLogToShow = ev.Entries.Count; if ( LastLogToShow = LastLogToShow - 2; i--) { EventLogEntry CurrentEntry = ev.Entries[i]; Console.WriteLine("Event ID : " + CurrentEntry.EventID); Console.WriteLine("Entry Type : " + CurrentEntry.EntryType.ToString()); Console.WriteLine("Message : " + CurrentEntry.Message + "\n"); } ev.Close();