如何从Java访问Windows事件查看器日志数据 [英] How do I access Windows Event Viewer log data from Java
问题描述
有没有办法从java类访问Windows事件日志。有没有人为此编写任何API,有没有办法从远程机器访问数据?
Is there any way to access the Windows Event Log from a java class. Has anyone written any APIs for this, and would there be any way to access the data from a remote machine?
场景是:
我在一个远程机器上运行一个进程,来自一个控制Java进程。
这个远程进程将东西记录到事件日志中,我希望能够在控制过程中看到它。
I run a process on a remote machine, from a controlling Java process. This remote process logs stuff to the Event Log, which I want to be able to see in the controlling process.
提前致谢。
推荐答案
在Java方面,您需要一个允许您进行本机调用的库。 Sun提供 JNI ,但听起来像排序痛苦还要考虑:
On the Java side, you'll need a library that allows you to make native calls. Sun offers JNI, but it sounds like sort of a pain. Also consider:
- https ://github.com/twall/jna/
- http://johannburkard.de/software/nativecall/
- http ://www.jinvoke.com/
- https://github.com/twall/jna/
- http://johannburkard.de/software/nativecall/
- http://www.jinvoke.com/
在Windows方面,你所追求的功能是 OpenEventLog 。这应该允许您访问远程事件日志。另请参阅查询活动信息。
On the Windows side, the function you're after is OpenEventLog. This should allow you to access a remote event log. See also Querying for Event Information.
如果这听起来不对,我也发现这个用于直接解析日志文件(不是我建议但有趣的方法):
If that doesn't sound right, I also found this for parsing the log files directly (not an approach I'd recommend but interesting nonetheless):
- http:// msdn.microsoft.com/en-us/library/bb309026.aspx
- http://objectmix.com/java/75154-regarding-windows-event-log-file-parser-java.html
- http://msdn.microsoft.com/en-us/library/bb309026.aspx
- http://objectmix.com/java/75154-regarding-windows-event-log-file-parser-java.html
这篇关于如何从Java访问Windows事件查看器日志数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!