How do I access Windows Event Viewer log data from Java

后端 未结 5 1505
不知归路
不知归路 2020-12-02 12:02

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

5条回答
  •  旧巷少年郎
    2020-12-02 12:18

    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/

    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

提交回复
热议问题