EvtClearLog function

Removes all events from the specified channel and writes them to the target log file.

Syntax

BOOL EvtClearLog(
  EVT_HANDLE Session,
  LPCWSTR    ChannelPath,
  LPCWSTR    TargetFilePath,
  DWORD      Flags
);

Parameters

Session

A remote session handle that the EvtOpenSession function returns. Set to NULL for local channels.

ChannelPath

The name of the channel to clear.

TargetFilePath

The full path to the target log file that will receive the events. Set to NULL to clear the log file and not save the events.

Flags

Reserved. Must be zero.

Return Value

Return code/value Description
TRUE
The function succeeded.
FALSE
The function failed. Use the GetLastError function to get the error code.

Remarks

To copy events from a channel or log file, call the EvtExportLog function.

You must specify the absolute path to the target log file; you cannot use relative paths and environment variables to specifying the target log file. The path can be a Universal Naming Convention (UNC) path. You should use .evtx as the file name extension.

This function affects only the channel—if the channel uses autoBackup or fileMax, this function will not affect those backup files.

Requirements

   
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header winevt.h
Library Wevtapi.lib
DLL Wevtapi.dll

See Also

EvtArchiveExportedLog

EvtExportLog