Enable Trace Logging for Failed Requests (IIS 7)
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
You can enable trace logging for failed requests when you want to log information about failed requests to an IIS site or application. When trace logging for failed requests is enabled, IIS provides targeted logging so that you no longer have to look through a list of irrelevant log entries to find a failed request. Additionally, you do not have to re-create an error in order to troubleshoot it.
You can configure:
The location of the log file
The maximum number of log files to keep
The maximum size of the log files
Prerequisites
For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see Tracing for Failed Requests Feature Requirements (IIS 7).
Exceptions to feature requirements
- None
Levels
- Web server
Required Permissions
- Web server administrator
To enable site-level trace logging for failed requests
You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
User Interface
To Use the UI
Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).
In the Connections pane, click Sites.
In Features View, select the site for which you want to enable trace logging.
In the Actions pane, under Configure, click Failed Request Tracing.
In the Edit Web Site Failed Request Tracing Settings dialog box, select Enable to enable logging for this site.
In the Directory text box, type the path where you want to store the log files or click the browse button (…) to find a location on the computer. The default is %SystemDrive%\inetpub\logs\FailedReqLogFiles.
Note
As a best practice, log files, such as log files for failed request tracing, should be stored in a directory other than systemroot.
- In the Maximum number of trace files text box, type the maximum number of trace log files that you want to keep, and then click OK.
Command-line
Enable failed request trace logging for a site
To enable trace logging for failed requests at the site level, use the following syntax:
**appcmd configure trace "site" /enablesite /directory:**string **/maxLogFiles:**int
The variable site is the name of the site for which you want to enable trace logging for failed requests. The variable directory string sets where you want to store the log files. The default is %SystemDrive%\inetpub\logs\FailedReqLogFiles. The variable maxLogFiles int sets the maximum number of trace log files that you want to keep. The default value is 50.
Enable failed request trace logging for a URL
To enable trace logging for failed requests at the URL level, use the following syntax:
**appcmd configure trace "site" /enable /directory:**string **/maxLogFiles:**int
The variable site is the name of the site for which you want to enable trace logging for failed requests. The variable directory string sets where you want to store the log files. The default is %SystemDrive%\inetpub\logs\FailedReqLogFiles. The variable maxLogFiles int sets the maximum number of trace log files that you want to keep. The default value is 50.
Note
You must first enable failed request trace logging for a site before you can enable failed request trace logging for a file or directory within that site. When you enable failed request trace logging for a URL, tracing is enabled, by default, for all trace providers, for all trace areas, and for the warning verbosity level.
For more information about Appcmd.exe, see Appcmd.exe (IIS 7).
Configuration
The procedure in this topic affects the following configuration elements:
- <traceFailedRequestLogging>
For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.
WMI
Use the following WMI classes, methods, or properties to perform this procedure:
Site.TraceFailedRequestsLogging.Enabled property
Site.TraceFailedRequestsLogging class
For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.