简体   繁体   中英

Get Event Logs from server in same domain (c#)

I'm running this kind of code to get local server logs, and it works as expected:

EventLog log = new EventLog("Security");
var entries = log.Entries.Cast<EventLogEntry>().Where(x => x.InstanceId == 4648).Select(x => new
                {
                    x.Message,
                    x.TimeGenerated
                }).ToList();

But I would like to get the logs from another server as well and concatenate the results. How can I contact the other server with c# and execute the same kind of code in the same application?

Many thanks in advance for your answers

The answer was

EventLog log = new EventLog("Security", "SERVERNAME");

Thanks to Bearcat9425 !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM