简体   繁体   English

如何在 Python 中从 Windows Server 的“应用程序和服务日志”中读取 TaskScheduler 日志

[英]How to read TaskScheduler logs in from Windows Server “application and services logs” in Python

How can I read (in Python) the logs from Windows Server 2008:如何从 Windows Server 2008 读取(在 Python 中)日志:

    Event Viewer
      Application and Services Logs
         Microsoft
            Windows
               Task Scheduler
                  Operational

Thanks,谢谢,

I don't know how you would do it with Python without tapping out to some sort of C/C++ support?我不知道如果不利用某种 C/C++ 支持,你会如何用 Python 做到这一点?

But, then I thought, maybe you could shell from python, and use LogParser ?但是,然后我想,也许您可​​以从 python 中取出外壳并使用LogParser Logparser can return nicely formatted output you could easily shred in python. Logparser 可以返回格式良好的输出,您可以轻松地在 python 中切碎。 However, if LogParser supports searching the extended log files, I couldn't get it to work on my Windows Server 2008 R2 server.但是,如果 LogParser 支持搜索扩展日志文件,我就无法让它在我的 Windows Server 2008 R2 服务器上运行。

But, then I thought, well, you could maybe tap out to PowerShell, surely?但是,然后我想,好吧,您肯定可以使用 PowerShell 吗? However, not using the get-eventlog cmdlet like I had thought would be the answer.但是,不要像我想象的那样使用get-eventlog cmdlet 就是答案。

Ultimately, I was able to query the event records of the log file "Microsoft-Windows-TaskScheduler/Operational", but I had to tap out to C# to do it from PowerShell.最终,我能够查询日志文件“Microsoft-Windows-TaskScheduler/Operational”的事件记录,但我必须使用 C# 才能从 PowerShell 执行此操作。

To sum up this sad story:总结一下这个悲伤的故事:

See Event Queries and Event Xml for samples on how to construct the query.有关如何构造查询的示例,请参阅事件查询和事件 Xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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