【发布时间】:2016-10-01 06:51:36
【问题描述】:
我正在尝试使用EventLog 获取与打印机相关的日志。
我已经枚举了系统中的所有日志,使用来自this question 的提示,如下所示:
foreach (var e in EventLogSession.GlobalSession.GetLogNames()) {
Console.WriteLine(e);
}
我得到了所需日志的日志名称 - Microsoft-Windows-PrintService/Operational。
但是,这段代码崩溃了:
var evt = new EventLog("Microsoft-Windows-PrintService/Operational");
与
An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll
Additional information: The event log 'Microsoft-Windows-PrintService/Operational' on computer '.' does not exist.
我在管理员下运行 MSVC 2015。
new EventLog("Application");
工作就像一个魅力,我如何创建自定义嵌套事件日志?
【问题讨论】: