다음을 통해 공유


Viewing IIS Event and Error Messages

IIS generates events in Event Viewer so that you can track the performance of IIS. Event Viewer tracks (in order of importance) error events, warning events, and informational events. The logs in Event Viewer provide an audited record of all Windows services and processes.

The Event Viewer is enabled by default in Windows. There are three types of logs in the Event Viewer: System, Security, and Application. For each type of log, you can set properties to filter the events to be viewed, designate the number of entries to view, specify how long to save entries, and specify whether to automatically overwrite existing events when the log becomes full. IIS events are logged in the Application log.

Opening the Event Viewer

You can open Event Viewer in any one of the following ways:

  • From the Start menu, click Run. In the Open box, type eventvwr. Click OK. - or -

  • Type start eventvwr at the command prompt, and press ENTER. - or -

  • From the Start menu, point to Administrative Tools, and then click Event Viewer. - or -

  • From the Start menu, point to Administrative Tools, and then click Computer Management.

    Event Viewer is listed under the System Tools node. The benefit of this display is that IIS Manager is in the same window under the Services and Applications node.

Parsing IIS Event and Error Logs

IIS administrators and developers who are creating IIS applications must sometimes quickly parse event and error logs to track the behavior of their applications.

IIS provides a tool called Log Parser that can search for data and patterns in log files, create reports, export data to a SQL Server database, and convert data between different log file formats. You can download Log Parser from Windows 2000 Tools and Utilities, or from IIS 6.0 Resource Kit Tools.

Configuring IIS to Log ASP Errors to the Event Viewer

IIS provides the following two metabase keys that enable you to specify which information is sent to the Event Viewer log when ASP errorsoccur.

  • AspErrorsToNTLog

    When set to TRUE, this property specifies that ASP errors are logged to both the Event Viewer and to the IIS log file.

    When set to FALSE, this property specifies that ASP errors are logged only to the IIS log file.

  • AspLogErrorRequests

    When set to TRUE, this property specifies that all ASP errors are logged.

    When set to FALSE, this property specifies that only a subset of all ASP errors are logged.

Example Code

The following code examples shows you how to use Visual Basic Scripting Edition (VBScript) and JScript to configure IIS so that all ASP errors that occur in the default Web site are logged to the event viewer. This example uses ADSI.

Set IIsWebVirtualDirObj = GetObject("IIS://localhost/W3SVC/1/Root") 

' There are multiple ways to set a property: IIsWebVirtualDirObj.AspErrorsToNTLog = True 
IIsWebVirtualDirObj.Put "AspLogErrorRequests", True IIsWebVirtualDirObj.SetInfo 

IIsWebVirtualDirObj.GetInfo 
WScript.Echo("Verify: AspErrorsToNTLog = " & IIsWebVirtualDirObj.AspErrorsToNTLog) 
WScript.Echo("Verify: AspLogErrorRequests = " & IIsWebVirtualDirObj.AspLogErrorRequests) 

var IIsWebVirtualDirObj = GetObject("IIS://localhost/W3SVC/1/Root"); 

// There are multiple ways to set a property: IIsWebVirtualDirObj.AspErrorsToNTLog = true; IIsWebVirtualDirObj.Put("AspLogErrorRequests", true); IIsWebVirtualDirObj.SetInfo(); 

IIsWebVirtualDirObj.GetInfo(); 
WScript.Echo("Verify: AspErrorsToNTLog = " + IIsWebVirtualDirObj.AspErrorsToNTLog); 
WScript.Echo("Verify: AspLogErrorRequests = " + IIsWebVirtualDirObj.AspLogErrorRequests);