EvtClearLog Function

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

Syntax

C++
BOOL WINAPI EvtClearLog(
  __in_opt  EVT_HANDLE Session,
  __in      LPCWSTR ChannelPath,
  __in_opt  LPCWSTR TargetFilePath,
  __in      DWORD Flags
);

Parameters

Session [in, optional]

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

ChannelPath [in]

The name of the channel to clear.

TargetFilePath [in, optional]

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 [in]

Reserved. Must be zero.

Return Value

Return code/valueDescription
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 clientWindows Vista
Minimum supported serverWindows Server 2008
HeaderWinEvt.h
LibraryWevtapi.lib
DLLWevtapi.dll

See Also

EvtArchiveExportedLog
EvtExportLog

Send comments about this topic to Microsoft

Build date: 11/12/2009

Tags :


Page view tracker