Using the EvtExportLog function, I currently fail to specify a correct value for the Path and/or Query parameter.
My goal is to export the local Application and System event log.
I've tried:
EvtExportLog(
IntPtr.Zero,
"Application",
"*",
"C:\\SomePath\\Application.evtx",
EventExportLogFlags.LogFilePath);
with the following P/Invoke definition:
[Flags]
private enum EventExportLogFlags
{
ChannelPath = 1,
LogFilePath = 2,
TolerateQueryErrors = 0x1000
};
[DllImport(@"wevtapi.dll",
CallingConvention = CallingConvention.Winapi,
CharSet = CharSet.Auto,
SetLastError = true)]
private static extern bool EvtExportLog(
IntPtr sessionHandle,
string path,
string query,
string targetPath,
[MarshalAs(UnmanagedType.I4)] EventExportLogFlags flags);
Unfortunately the function returns false and a last error code of 2 (ERROR_FILE_NOT_FOUND).
My question:
What to put in the Path and Query parameters to export the local Application and System event log?