EventLog Component
Use the EventLog component to write messages to a Windows event log. The Identity properties of the EventLog define the log to which the messages are written. The Identity properties of the EventLog component, LogName, MachineName, and Source, are accessed from the Properties grid and are set at design time. You can also set the identity of the event log by using the EventLog component's SetEventLogIdentity method. Note that the settings in the Diagnostics Configuration dialog do not apply to event messages generated from the EventLog component.
The default Identity properties for the EventLog component are shown here:
LogName: OS_AUTOMATION, Source: OpenSpan Automation, Machine: . (current computer)
Studio tries to create this log when the EventLog.WriteLog() method is called. If the user running the Studio project does not have sufficient Windows account privileges, the log is not created.
You can change the default Identity for the EventLog component either through changing the LogName, MachineName, and Source properties in the Properties grid, or set the Identity dynamically in an automation by using the SetEventLogIdentity method.
Note: Event log and event source creation are privileged operations. Creation of a new event log, new event source, or reassignment of an existing event source to a different event log is an administrative operation and must be done under an Admin user's credentials. If the deployed project uses the SetEventLogIdentity method, the logged-in user running the project must have Admin credentials, otherwise, security-related errors will occur.
Therefore, when using the EventLog in projects set the EventLog component Identity to a log that has already been created, such as the Application event log which is always available on a client machine.
Component Property, Methods, and Events
The properties, methods, and events specific to the EventLog component follow. For more information, see General Component Properties, Methods, and Events.
Properties
Property |
Description |
Behavior properties |
|
Enabled |
Enables/disables writing to the event log. |
EventType |
Sets the default event type used if the event type is not specified as a parameter of the WriteLog method. The types are:
|
LogLevel |
Sets the minimum severity (event type) required to write a message to the log. Set this property to increase or decrease the sensitivity of events that will be logged. The log levels options are the same as those listed for the EventType. Messages with an event type lower than the value set in this property will not be written to the log. For example, if the LogLevel is set to Information, messages are written to the log for event types: Information, Warning, and Error. If the LogLevel is set to Error, message are written to the log for Error event types. |
Event log metrics |
|
MaximumKilobytes |
Sets the capacity of the event log in kilobytes. |
MinimumRetentionDays |
Sets the number of days to retain events in the event log before overwriting. This setting only applies when the OverflowAction property is set to OverwriteOlder. |
OverflowAction |
Specifies the action to take when writing events to the event log when it has reached its configured capacity as specified in the MaximumKilobytes property. Your options are:
|
Identity (See the Default Event Log Identity description above.) |
|
LogName |
Sets the name of the event log to which the EventLog writes messages. |
MachineName |
Sets the name of the computer on which the event log exists and where the EventLog writes messages. Use a period (.) to indicate the local machine. |
Source |
Sets source of the event used for logging events with the EventLog component. The source is written in the event header along with the Date, Time, EventID, and so on. |
Methods
Method |
Description |
Parameters |
Result Type |
ClearLog |
Clears the contents of the event log. |
None |
Void |
DeleteLog |
Deletes the event log. |
None |
Void |
GetLogName |
Returns the name of the event log. |
None |
String |
GetMachineName |
Returns the name of the computer the event log is on. |
None |
String |
GetSource |
Returns the current source associated with the event log. |
None |
String |
GetTable |
Returns a DataTable containing the current message in the event log specified by the Identity properties or set by the SetEventLogIdentity method. This table can be bound as a data source to controls such as data grids to allow the display and search of event log messages. |
None |
DataTable |
SetEventLogIdentity (2 Parameters) |
Changes the identity of the event log from that specified by the Identity properties to the event log designated by the input arguments. If the event log or source does not exist, it will attempt to create them. For more information, see Setting Event Log Identity. |
String logName, String source |
Void |
SetEventLogIdentity (3 Parameters) |
Changes the identity of the event log from that specified by the Identity properties to the event log designated by the input arguments. If the event log or source does not exist, it will attempt to create them. For more information, see Setting Event Log Identity. |
String logName, String source, String machineName |
Void |
WriteLog (1 Parameter) |
Writes an entry to the log with the message supplied. The message will be written using the event type specified by the EventType property for the component. |
String message |
Void |
WriteLog (2 Parameters) |
Writes an entry to the log with the message and event type supplied. |
String message, EventLogEntryType eventType |
Void |
WriteLog (3 Parameters) |
Writes an entry to the log with the message, event type, and event ID supplied. |
String message, EventLogEntryType eventType, Int32 eventId |
Void |
WriteLog (4 Parameters) |
Writes an entry to the log with the message, event type, event ID, and category ID supplied. |
String message, EventLogEntryType eventType, Int32 eventId, Int32 categoryId |
Void |
WriteLog (5 Parameters) |
Writes an entry to the log with the message, event type, event ID, category ID, and data bytes supplied. |
String message, EventLogEntryType eventType, Int32 eventId, Int32 categoryId, Byte[] rawData |
Void |
Related information
Privacy | Trademarks | Terms of Use | Feedback
Updated: 01 July 2024
© 2016 - 2024 Pegasystems Inc. Cambridge, MA All rights reserved.