|
Servertec Foundation Classes 1.3.3 09/04/2005 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstec.sfc.Win32.EventLog
public final class EventLog
Used to add and remove event log sources and to add, read, backup and clear messages in the Windows NT/2000/XP event log.
Local Mode is used to resolve EventLogRecord external refernces such as Category, Expanded Parameters, Message and User Name using resources relative to the computer the EventLog is on. Defaults to true.
Raw Mode is used to retrieve EventLogRecords without resolving external references such as User Name. Defaults to false.
Field Summary | |
---|---|
static java.lang.String |
APPLICATION
Used when adding sources to the Application log. |
static int |
BACKWARDS_READ_DIRECTION
Read backwards. |
static int |
FORWARDS_READ_DIRECTION
Read forwards. |
static java.lang.String |
SECURITY
Used when adding sources to the Security log. |
static java.lang.String |
SYSTEM
Used when adding sources to the System log. |
Constructor Summary | |
---|---|
EventLog(java.lang.String eventlog)
Creates a new EventLog object. |
|
EventLog(java.lang.String hostname,
java.lang.String eventlog)
Creates a new EventLog object. |
|
EventLog(java.lang.String hostname,
java.lang.String eventlog,
boolean register_event_source)
Creates a new EventLog object. |
Method Summary | |
---|---|
static void |
addSource(java.lang.String eventlog,
java.lang.String name,
java.lang.String path,
int events,
int categories)
Adds the named event source to the specified event log. |
void |
backup(java.lang.String filename)
Used to backup the event log to the specified file. |
void |
clear()
Clears the event log. |
void |
clear(java.lang.String filename)
Used to backup and clear the event log. |
void |
close()
Close the event log. |
EventLogRecord |
get(int record_number)
Returns the specified EventLogRecord. |
EventLogRecord |
get(int record_number,
int read_direction)
Returns the specified EventLogRecord. |
java.lang.String |
getEventLog()
Returns the name of the event log being used. |
java.lang.String |
getHostname()
Returns the name of the computer whose event log is being used. |
boolean |
isFull()
Returns whether the event log is full. |
boolean |
localMode()
Returns whether the EventLogRecords will use resources relative to the computer the EventLog is on to resolve Category, Expanded Parameters, Message and User Name. |
void |
localMode(boolean local_mode)
Sets whether the EventLogRecords will use local resources relative to the computer the EventLog is on to resolve Category, Expanded Parameters, Message and User Name. |
void |
log(int event_type,
int categoryid,
int eventid,
java.lang.String[] parameters,
byte[] data)
Adds the specified message to the event log. |
void |
log(int event_type,
int categoryid,
int eventid,
java.lang.String[] parameters,
byte[] data,
int bytes)
Adds the specified message to the event log. |
void |
log(int event_type,
java.lang.String parameter)
Adds the specified message to the event log. |
void |
log(int event_type,
java.lang.String[] parameters)
Adds the specified message to the event log. |
EventLogRecord |
next()
Returns the next EventLogRecord. |
EventLogRecord |
previous()
Returns the previous EventLogRecord. |
boolean |
rawMode()
Returns whether the EventLogRecords are retrieved in raw mode. |
void |
rawMode(boolean raw_mode)
Sets whether the EventLogRecords are to be retrieved in raw mode. |
static void |
removeSource(java.lang.String eventlog,
java.lang.String name)
Removes the named event source from the specified event log. |
int |
size()
Returns the number of events in the current event log. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BACKWARDS_READ_DIRECTION
Set to EVENTLOG_BACKWARDS_READ.
public static final int FORWARDS_READ_DIRECTION
Set to EVENTLOG_FORWARDS_READ.
public static final java.lang.String APPLICATION
public static final java.lang.String SECURITY
public static final java.lang.String SYSTEM
Constructor Detail |
---|
public EventLog(java.lang.String eventlog) throws Win32Exception
eventlog
- the name of the event log.
If Servertec Win32 event source is being used set this value to sfc.
Win32Exception
- if any error occurs.public EventLog(java.lang.String hostname, java.lang.String eventlog) throws Win32Exception
hostname
- the name of the computer whose log will be used.eventlog
- the name of the event log.
If Servertec Win32 event source is being used set this value to sfc.
Win32Exception
- if any error occurs.public EventLog(java.lang.String hostname, java.lang.String eventlog, boolean register_event_source) throws Win32Exception
hostname
- the name of the computer whose log will be used.eventlog
- the name of the event log.register_event_source
- whether to just open the event log or whether to also register the event source. Must be true when using log() otherwise can be false.
If Servertec Win32 event source is being used set this value to sfc.
Win32Exception
- if any error occurs.Method Detail |
---|
public final void close() throws Win32Exception
Win32Exception
- if any error occurs.public static final void addSource(java.lang.String eventlog, java.lang.String name, java.lang.String path, int events, int categories) throws Win32Exception
eventlog
- the name of the event log.
Normally Application is used. Other predefined event logs are Security and System.
If Servertec Win32 event source is being used set this value to Application.
name
- the name of the new event source.
If Servertec Win32 event source is being used set this value to sfc.
path
- the path to the .exe or .dll containing event source messages.
If Servertec Win32 event source is being used set this value to sfc_dirbin\sfc_wnt.dll in Windows NT or sfc_dirbin\sfc_w2k.dll in Windows 2000/XP.
events
- the EventLogType.categories
- the number of event categories.
If Servertec Win32 event source is being used set this value to 1.
Win32Exception
- if any error occurs.public static final void removeSource(java.lang.String eventlog, java.lang.String name) throws Win32Exception
Once an event source is removed, messages for that event source will not be available for viewing.
eventlog
- the name of the event log.
If Servertec Win32 event source is being used set this value to Application.
name
- the name of the event source to remove.
If Servertec Win32 event source is being used set this value to sfc.
Win32Exception
- if any error occurs.public final int size() throws Win32Exception, java.io.IOException
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final void log(int event_type, int categoryid, int eventid, java.lang.String[] parameters, byte[] data, int bytes) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException
event_type
- the EventLogType.categoryid
- the category identifier.
If Servertec Win32 event source is being used set this value to 1.
eventid
- the event identifier.
If Servertec Win32 event source is being used set this value to 0.
parameters
- the array of Strings containing any progameter to the message to add to the event log.
If Servertec Win32 event source is being used use a single dimension String array containing a single String.
data
- the byte array of binary data to log.bytes
- the number of bytes of binary data to log.
java.lang.ArrayIndexOutOfBoundsException
- if the length of the specified parameters string array is zero (0) or if the specified number of bytes to log is larger than the specified byte array.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final void clear(java.lang.String filename) throws Win32Exception, java.io.IOException
filename
- the name of the file to backup the event log to.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if the file already exists or if any error occurs.public final void backup(java.lang.String filename) throws Win32Exception, java.io.IOException
filename
- the name of the file to backup the event log to.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if the file already exists or if any error occurs.public final void log(int event_type, java.lang.String parameter) throws Win32Exception, java.io.IOException
event_type
- the EventLogType.parameters
- the array of Strings containing any progameter to the message to add to the event log.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final void log(int event_type, java.lang.String[] parameters) throws Win32Exception, java.io.IOException
event_type
- the EventLogType.parameters
- the array of Strings containing any progameter to the message to add to the event log.
If Servertec Win32 event source is being used use a single dimension String array containing a single String.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final void log(int event_type, int categoryid, int eventid, java.lang.String[] parameters, byte[] data) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException
event_type
- the EventLogType.categoryid
- the category identifier.
If Servertec Win32 event source is being used set this value to 1.
eventid
- the event identifier.
If Servertec Win32 event source is being used set this value to 0.
parameters
- the array of Strings containing any progameter to the message to add to the event log.
If Servertec Win32 event source is being used use a single dimension String array containing a single String.
data
- the byte array of binary data to log.
java.lang.ArrayIndexOutOfBoundsException
- if the length of the specified parameters string array is zero (0) or if the specified number of bytes to log is larger than the specified byte array.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final void clear() throws Win32Exception, java.io.IOException
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final EventLogRecord get(int record_number, int read_direction) throws java.lang.IllegalArgumentException, Win32Exception, java.io.IOException
record_number
- the record number starting at 0 to size() - 1.read_direction
- the read direction.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.
java.lang.IllegalArgumentException
public final EventLogRecord get(int record_number) throws Win32Exception, java.io.IOException
record_number
- the record number starting at 0 to size() - 1.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final EventLogRecord previous() throws Win32Exception, java.io.IOException
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final EventLogRecord next() throws Win32Exception, java.io.IOException
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final boolean isFull() throws Win32Exception, java.io.IOException
Requires Windows 2000/XP.
java.io.IOException
- the EventLog has been closed.
Win32Exception
- if any error occurs.public final boolean rawMode()
EventLogRecord.getUserNames() returns the username when Raw Mode is false and returns the SID when Raw Mode is true or when Raw Mode is false and the username cannot be found.
public final void rawMode(boolean raw_mode)
EventLogRecord.getUserNames() returns the username when Raw Mode is false and returns the SID when Raw Mode is true or when Raw Mode is false and the username cannot be found.
raw_mode
- whether the EventLogRecords are to be retrieved in raw mode.public final boolean localMode()
public final void localMode(boolean local_mode)
local_mode
- whether the EventLogRecords will use resources relative to the computer the EventLog is on.public final java.lang.String getHostname()
public final java.lang.String getEventLog()
|
Servertec Foundation Classes 1.3.3 09/04/2005 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2001-2005 Servertec. All rights reserved.