I have googled lots of possible answers with no luck. I am trying to extract the following from the Event Log (pseudo-code):
select events
where
event date/time between FromDateTime and ToDateTime
and
((Level<=2) // error, critical only
or
((Level<=x) and Provider[Name] in a specific list) // any messages for these apps
)
(The second "Level" expression is to allow the user to specify whether to include Informational messages or limit to Warnings and above, so I can't just discard it.)
The following is the (latest) expression I am trying to use - unsucessfully.
string queryString =
"*[System[TimeCreated[@SystemTime>='" + dFrom + "' and @SystemTime<='" + dTo + "']]] " +
" and " +
"(*[System[Level<=2]]" +
" or " +
" ( " +
" *[System[Provider[@Name='<1st name>' or @Name='<2nd name>' or @Name='<3rd name>]] " +
" and " +
"System[Level<=" + maxLevel.ToString() + "]]" +
")" +
");"
Am I trying to make an expression that is too hard for the Event Log query evaluator, or do I just have a simple error in the expression? I have been trying various forms of the expression. It appears that the "Level" filters are just being ignored, but why?