• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How do I get events from "Event Viewer" (Windows Administrative Tools) using Java?

 
Ranch Hand
Posts: 701
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In Windows XP we can see all the events that happened in the computer:

Start --> Control Panel --> Performance and Maintenance --> Administrative Tools --> Event Viewer --> System Log


I'd like to get the time I started and the time I turned off my computer, through a java application.

I've heard that JNI might be used. Has someone already made something like this before?


Thank you.
 
Sheriff
Posts: 22855
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Download Log4J - they have an appender which can add to the event log. Perhaps you can use that as a base for your own native code. The Log4J source code is freely available.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will have to use JNI. No standard Java API right now provides you this sort of feature to query the event log. Win32 SDK provides all features for system access. The API to read event log is there. You need to use that API from your JNI code.

Its a 2 step process:

1. Writing Java interfaces which make use of events, event categories (Application, System, Error etc) exposed in Java
2. Interface methods mapped to native JNI mehotds (native methods to be implemented in C++ or C using Win 32 SDK)


To carry out these steps you may have to study :

1. How JNI works
2. The Win 32 SDK API for EventLog

* While programming for EventLogs, you wll find lots of other interesting APIS like Performance counters, Windows Registry,.... .. Its actually very tempting
 
Josh Wild
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.. And yes you will then be able to track log in, log out and other system events.. See there is a well designed structure of events... Each standard event like system login or logout has an event code. Once you are able to expose the low level Windows events to Java, you can access all sorts of information regarding an event.

The event code for 'System Login' is '6009' by the way
reply
    Bookmark Topic Watch Topic
  • New Topic