>>--open(--+---------+--+------------+--)-----------------------><
+-server--+ +-,--source--+Opens the specified event log. Once an event log is opened, other methods of the WindowsEventLog instance will use that opened log until it has been closed.
If an event log is already open, then it is first closed before the specified log is opened.
The arguments are:
Optional. The name of the server where the event log resides.
Optional. The event source.
This method returns 0 on success, and the operating system error code on failure.
The following two code snippets are equivalent. They both open the Application log on the local machine if they succeed:
eventLog1 = .WindowsEventLog~new ret = eventLog1~open if ret \== 0 then do say 'Failed to open the event log:' say ' Error' ret':'SysGetErrortext(ret) ... end eventLog2 = .WindowsEventLog~new ret = eventLog2~open( , "Application") if ret \== 0 then do say 'Failed to open the event log' say ' Error' ret':'SysGetErrortext(ret) ... end
The following example opens the System log on SERVER01:
eventLog = .WindowsEventLog~new
ret = eventLog~open("\\SERVER01", "System")
if ret == 0 then do
-- Do something with the event log
...
eventLog~close
...
end
else do
-- Handle the error in some way
...
end