如何从 Java 访问 Windows 事件查看器日志数据 [英] How do I access Windows Event Viewer log data from Java

查看:29
本文介绍了如何从 Java 访问 Windows 事件查看器日志数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从 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:

在 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):

这篇关于如何从 Java 访问 Windows 事件查看器日志数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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