SELECT
query. Then, as the processed data comes out of the pipeline, you can output it to text files, HTML files, Excel-style charts, or a SQL database table, or simply to the console as raw output. Putting these into proper syntax, a typical Log Parser command looks something like this:
logparser -i:<Input_Format> -o:<Output_format> <SQL_statement>
logparser "SELECT * FROM System" -i:EVT
System 2096 2005-06-17 05:01:14 2005-06-17 05:01:14 7035
4 Information event 0 None Service Control Manager
Fax|stop BOX15 S-1-5-18 The Fax service was successfully
sent a stop control.
Information
that has an event ID of
7035
and an event source of
Service Control Manager
. Log Parser will display these events ten at a time, prompting you for a keystroke to continue or Ctrl-C to abort.
Error
, as these are likely to be of some importance to us:
logparser "SELECT * FROM System WHERE EventTypeName='Error event'" -i:EVT
Error
events:
System 975 2005-05-10 16:40:09 2005-05-10 16:40:09
10010 1 Error event 0 None DCOM
{601AC3DC-786A-4EB0-BF40-EE3521E70BFB} BOX15
S-1-5-21-2696947089-119843295-2143939133-500
The server {601AC3DC-786A-4EB0-BF40-EE3521E70BFB}
did not register with DCOM within the required
timeout.
Error
events are we getting in our machine's System log? Let's output only the event sources this time:
logparser "SELECT SourceName FROM System WHERE
EventTypeName='Error event'" -i:EVT
SourceName
-----------------------
DCOM
Service Control Manager
Service Control Manager
Service Control Manager
Service Control Manager
Service Control Manager
Service Control Manager
Service Control Manager
W32Time
W32Time
Press a key...
Error
events in our System log, and how many of each source type were recorded? Log Parser can easily tell us this:
logparser "SELECT SourceName, COUNT(*) FROM System WHERE
EventTypeName='Error event' GROUP BY SourceName" -i:EVT
SourceName COUNT(ALL *)
----------------------- ------------
DCOM 5
Service Control Manager 43
W32Time 8
NETLOGON 3
NETLOGON
errors may be important, so let's key in on those and display the event IDs for these events plus the date and time they were generated (sorted in descending order):
|
logparser "SELECT TimeGenerated,EventID FROM System WHERE
EventTypeName='Error event' AND SourceName='NETLOGON' ORDER BY
TimeGenerated DESC" -i:EVT
TimeGenerated EventID
------------------- -------
2005-06-18 16:44:00 5719
2005-06-18 16:39:19 5719
2005-05-19 08:12:33 5719
5719
? Let's use Log Parser to find out:
logparser "SELECT EventID,Message FROM System WHERE EventID=5719" -i:EVT
5719 No Domain Controller is available for domain MTIT
due to the following: There are currently no logon servers
available to service the logon request. Make sure that the
computer is connected to the network and try again. If the
problem persists, please contact your domain administrator.
SELECT
statements. A good resource for learning the basics is SQL Tutorial from FirstSQL.
logparser -h
and viewing the Help information displayed.
|
Related Reading
Microsoft Log Parser Toolkit
By Gabriele Giuseppini, Mak Burnett |