+-server--+  +-,-source-+  +-,-backupFileName-+

Clears (removes) all event records from the log. Optionally will back up the log first. When the optional backup file name is supplied and for some reason the back up fails, then the event records are not cleared.


The arguments are:


Optional. The name of the server where the event log resides


Optional. The event source.


Optional. The path name to a back up file. If this argument is specified, the event log is first backed up before it is cleared. If the back up fails, the log is not cleared. The back will fail if the file name specified already exists.

The back up file will be created on the system that the event log file itself is on. This means that if an event log on a remote system is specified, the log will be created on that remote system. The file name must therefore be a valid file name on the remote system.

If the file name does not contain an extension, the the normal extension for event log back ups, .evt, will be used.

Return value:

This method returns 0 on success, and the operating system error code on failure.


This example backs up the Application event log on the remote Eagle system and then clears the log. If the back up fails, the log will not be cleared. The back up file will be named eagle_application.evt and will be located on the Eagle system, not on the local machine.

  log = .WindowsEventLog~new

  ret = log~open("\\Eagle", "Application")
  if ret == 0 then do
    ret = log~clear( , , "C:\eagle_application")
    if ret == 0 then do
      say 'Backed up the Application event log on Eagle to:'
      say '  C:\eagle_application.evt on the Eagle system.'
    else do
      say 'Failure backing up event log:' ret ":" SysGetErrorText(ret)

::requires 'winSystm.cls'