Microsoft KB Archive/315410

= How To Use the Event Logging Utility (Logevent.exe) to Create and Log Custom Events in Event Viewer in Windows 2000 =

Article ID: 315410

Article Last Modified on 2/28/2007

-

APPLIES TO


 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition

-



This article was previously published under Q315410



IN THIS TASK
SUMMARY Overview of Logevent.exe Examples
 * How to Log an Entry on the Local Computer
 * How to Log an Entry on a Remote Computer

How to View Application Log Events in Event Viewer REFERENCES



SUMMARY
This step-by-step article describes how to use the Event Logging utility (Logevent.exe) to create and to log custom events to the Application Log of Event Viewer. Logevent.exe is included in the Windows 2000 Resource Kit. You can start Logevent.exe by using either the command prompt or a batch file, and you can use the tool to create entries in the Application Log of either a local or a remote Windows 2000-based computer.

Logevent.exe is useful when you want to log error information or status information from batch programs that you run by using logon scripts or by using the AT command. You can call Logevent.exe from a batch file, and then use it to log the information to the Application Log. Logevent.exe can store entries in the logs of other computers; therefore, you can record data in a central location.

back to the top

Overview of Logevent.exe
Logevent.exe uses the following syntax:

logevent -m \\ -s -c  -r  -e  -t  &quot; &quot;

The following list describes the parameters that you can use with Logevent.exe:  -m \\ : Use this parameter to specify the name of the computer on which the event is logged. If you omit this parameter, the event is logged on the local computer. This parameter is mapped to the Computer section of the event header when you view the event in Event Viewer. -s : Use this parameter to specify the severity level of the logged event, where   is one of the following categories:   S : Success  I : Information (This is the default setting. If you do not specify a severity level, Logevent.exe uses I .)  W : Warning  E : Error  F : Failure</li></ul>

This parameter is mapped to the Type section of the event header when you view the event in Event Viewer.

</li> -c : Use this parameter to specify the category number of the logged event. If you do not type a number, Logevent.exe uses the default value 0 (none). This parameter is mapped to the Category section of the event header when you view the event in Event Viewer.</li> -r : Use this parameter to specify the source of the logged event (for example, the name of the program or script). You must use double quotes to enclose strings that contain spaces. If you do not specify a string, Logevent.exe uses the User Event default string. This parameter is mapped to the Source section of the event header when you view the event in Event Viewer.</li> -e : Use this parameter to assign an event ID number to the logged event. You can use integers from 0 to 65535. If you do not assign a value, Logevent.exe uses 1 (the default value). This parameter is mapped to the Event ID section of the event header when you view the event in Event Viewer.</li> -t : Use this parameter to specify the time that Logevent.exe waits to create a log entry. Logevent.exe quits after the log entry is created. By default, Logevent.exe waits 60,000 milliseconds (1 minute).</li> &quot; &quot;: Use this parameter to type a description for the logged event. You must use double quotes to enclose strings that contain spaces, for example, &quot;This is my message.&quot; This parameter is mapped to the Description section when you view the event in Event Viewer.</li></ul>

back to the top

How to Log an Entry on the Local Computer
To record an Information entry in the Application Log of the local computer, either use the following line in a batch file or type it at a command prompt, and then press ENTER:

logevent &quot;This is a test&quot;

When you view the event details in Event Viewer for this example, an entry similar to the following is displayed: <pre class="fixed_text">  Date:      01/01/2002   Source:    User Event Time:     8:16         Category:  None Type:     Information  Event ID:  1 User:     N/A Computer: MYCOMPUTER <pre class="fixed_text">  Description: The description for Event ID ( 1 ) in Source ( User Event) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event: This is   a test. back to the top

How to Log an Entry on a Remote Computer
To log a Warning entry on a remote computer named &quot;Server1,&quot; with a category code of 100, and an event ID number of 88, either use the following line in a batch file or type it at the command prompt, and then press ENTER:

logevent -m \\server1 -s W -c 100 -r &quot;my batch program&quot; -e 88 &quot;batch program failed!&quot;

When you view the event details in Event Viewer for this example, an entry similar to the following is displayed: <pre class="fixed_text">  Date:      01/01/2002   Source:    my batch program Time:     8:30         Category:  (100) Type:     Warning      Event ID:  88 User:     N/A Computer: SERVER1 <pre class="fixed_text">  Description: The description for Event ID ( 88 ) in Source ( my batch program ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event: batch program failed! back to the top

How to View Application Log Events in Event Viewer
To view events in the Application Log of Event Viewer:
 * 1) Click Start, point to Settings, and then click Control Panel.
 * 2) Double-click Administrative Tools, then double-click Event Viewer.

NOTE: Alternatively, you can start Event Viewer by starting the Microsoft Management Console (MMC) program that contains the Event Viewer snap-in.
 * 1) Click to expand Event Viewer (if it is not already expanded).
 * 2) Click Application.

The events that are logged in the Application Log are displayed in the right details pane.
 * 1) To view more details about a specific event, double-click the event that you want to view.
 * 2) To copy the details of the event, click the Copy button, open a new document using the program in which you want to paste the event (for example, Microsoft Word), and then click Paste on the Edit menu.
 * 3) To view the description of the previous or next event, click the up or down arrow.

back to the top

<div class="references_section">