How to write from Java to the Windows Event Log?

后端 未结 4 2180
你的背包
你的背包 2020-12-14 17:48

How can I write from Java to the Windows Event Log?

4条回答
  •  孤城傲影
    2020-12-14 17:56

    You can also use the eventcreate command on Windows XP Pro and above.

    String command = "eventcreate "
                   + " /l APPLICATION"
                   + " /so \"" + applicationObjectName + "\""
                   + " /t " + lvl
                   + " /id " + id
                   + " /d \"" + description + "\"";
    
    Runtime.getRuntime().exec(command);
    

    For XP home and lower, you could create a vbs application that writes using the wscript.shell.eventcreate method. However you sacrifice the ability to specify source.

    Example: http://www.ozzu.com/mswindows-forum/posting-event-log-with-batch-files-t76791.html

提交回复
热议问题