Samples‎ > ‎WinPack Samples‎ > ‎

Event Log Sample

import com.jniwrapper.win32.system.eventlog.EventLog;
import com.jniwrapper.win32.system.eventlog.EventLogMessage;

import java.util.List;

/**
 * This sample prints out all messages from the
 * "Application" event log.
 */
public class EventLogSample
{
    public static void main(String[] args)
    {
        EventLog eventLog = new EventLog("Application");
        List messages = eventLog.getMessages();
        for (int i = 0; i < messages.size(); i++)
        {
            EventLogMessage eventLogMessage = (EventLogMessage)messages.get(i);
            System.out.println(eventLogMessage.getRecordNumber() + "\t" + eventLogMessage.getDate());
        }
    }
}