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.
Lalit MPosted Dec 3, 2009, 4:02 AM
i find code fore read/write event log of local computer and remote computer,you can also this code sample
complete reference you can go through from this link.
chandrasekhar ravuriPosted Dec 3, 2009, 3:42 AM
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()
Naeem AhmedPosted May 28, 2009, 12:18 PM
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.
Niradhip ChakrabortyPosted May 26, 2009, 2:50 PM
http://www.artima.com/forums/flat.jsp?forum=152&thread=135902