Go to Robotic Automation version 22.1 documentation

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.

 

Default Event Log Identity

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.

 

Setting Event Log Identity

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:

  • Information – An event that describes the successful operation of a task, such as an application, driver, or service. For example, an information event is logged when a network driver loads successfully.

  • Warning – An event that is not necessarily significant, however, may indicate the possible occurrence of a future problem. For example, a warning message is logged when disk space starts to run low.

  • Error – An event that describes a significant problem, such as the failure of a critical task. Error events may involve data loss or loss of functionality. For example, an error event is logged if a service fails to load during startup.

  • Success Audit (Security log) – An event that describes the successful completion of an audited security event. For example, a success audit event is logged when a user logs on to the computer.

  • Failure Audit (Security log) – An event that describes an audited security event that did not complete successfully. For example, a failure audit may be logged when a user cannot access a network drive.

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:

  • Overwrite Older – Use this parameter to overwrite events that are older than the MinimumRetentionDays property value. If the log is full and there are no events old enough to be overwritten, new events are discarded.

  • Do Not Overwrite – Use this parameter to specify that you do not want to overwrite events. When the log is full, new events are discarded. To record new events, you must clear the log.

  • Overwrite As Needed – Use this parameter if you want to overwrite the oldest events in the log with new events.

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

Using the EventLog Component

Event Logging - Log Types

 


Privacy | Trademarks | Terms of Use | Feedback

Updated: 01 July 2024

© 2016 - 2024 Pegasystems Inc.  Cambridge, MA All rights reserved.

 

OpenSpan data classification label