您好我正在尝试使用 c# 查看远程计算机中的事件日志。我只想使用 Source Enterprise Library Logging 获取日志。下面的代码在本地机器上运行良好。要连接到远程机器,我需要模拟或提供一些凭据,这些凭据将使代码通过远程服务器进行身份验证。我如何在这里进行模拟:
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);