如何指定事件在内心深处与QUOT;应用程序和服务日志"? [英] How do I specify events deep inside "Applications and Services Logs"?

查看:126
本文介绍了如何指定事件在内心深处与QUOT;应用程序和服务日志"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面code片段触发时记录事件的事件。样品code工作正常,但我要监控的日志实际上是应用程序和服务日志>微软>窗口>任务计划>运行。

我怎么插到位的code样本中的应用程序?

  ...
事件日志myNewLog =新事件日志(应用程序,testEventLogEvent。);

myNewLog.EntryWritten + =新EntryWrittenEventHandler(MyOnEntryWritten);
myNewLog.EnableRaisingEvents = TRUE;
...
 

解决方案

日志名为微软的Windows的TaskScheduler /运营,但我不认为你可以访问使用它的EventLog类。我认为,日志基于Windows事件跟踪,所以你需要使用的 System.Diagnostics.Eventing.Reader命名空间访问它。

借助事件日志方案页面可能是有用的,特别是如何:订阅事件在事件日志的文章可以帮助你开始了。

更新:该如何:订阅事件在事件日志中code为我工作后,我改变了日志名称(我也改变了查询请求级别= 4)..

  EventLogQuery subscriptionQuery =新EventLogQuery(
    微软的Windows的TaskScheduler /运行,PathType.LogName,* [系统/等级= 4]);
 

The following code snippet fires an event when an event is logged. The sample code works fine but the log I want to monitor is actually "Applications and Services Logs > Microsoft > Windows > Task Scheduler > Operational".

What do I insert in place of "Application" in the code sample?

...
EventLog myNewLog = new EventLog("Application", ".", "testEventLogEvent");                 

myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
myNewLog.EnableRaisingEvents = true;
...

解决方案

The log name is Microsoft-Windows-TaskScheduler/Operational but I don't think you can access it using the EventLog class. I think that log is based on Event Tracing for Windows so you need to use the System.Diagnostics.Eventing.Reader namespace to access it.

The Event Log Scenarios page might be useful, in particular the How to: Subscribe to Events in an Event Log article might help you get started.

Update: The How to: Subscribe to Events in an Event Log code worked for me after I changed the log name (I also changed the query to request Level=4)...

EventLogQuery subscriptionQuery = new EventLogQuery(
    "Microsoft-Windows-TaskScheduler/Operational", PathType.LogName, "*[System/Level=4]");

这篇关于如何指定事件在内心深处与QUOT;应用程序和服务日志"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆