Trace Failed Requests <traceFailedRequests>
2015-12-02 02:42
501 查看
https://www.iis.net/configreference/system.webserver/tracing/tracefailedrequests
Overview
The
allows you to configure failed request tracing for a Web site, application, or directory. This element can contain a collection of
that define tracing rules, each of which specifies the extension of the request URL to which the rule applies, the trace providers and areas to enable, and the conditions that cause this rule to log the events.
After you finish the default installation of IIS 7 and later, you must install the tracing role service to use failed request tracing. After you install the role service, you still must enable failed request tracing at the site level, application level, or
directory level.
On the taskbar, click Server
Manager.
In Server
Manager, click the Manage menu,
and then click Add
Roles and Features.
In the Add
Roles and Features wizard, click Next.
Select the installation type and click Next.
Select the destination server and click Next.
On the Server
Roles page, expand Web
Server (IIS), expand Web
Server, expand Health
and Diagnostics, and then select Tracing.
Click Next.
.
On the Select
features page, click Next.
On the Confirm
installation selections page, click Install.
On the Results page,
click Close.
On the Start screen,
move the pointer all the way to the lower left corner, right-click the Start button,
and then clickControl
Panel.
In Control
Panel, click Programs
and Features, and then click Turn
Windows features on or off.
Expand Internet
Information Services, expand World
Wide Web Services, expand Health
and Diagnostics, and then select Tracing.
Click OK.
Click Close.
On the taskbar, click Start,
point to Administrative
Tools, and then click Server
Manager.
In the Server
Manager hierarchy pane, expand Roles,
and then click Web
Server (IIS).
In the Web
Server (IIS) pane, scroll to the Role
Services section, and then click Add
Role Services.
On the Select
Role Services page of the Add
Role Services Wizard, select Tracing,
and then click Next.
On the Confirm
Installation Selections page, click Install.
On the Results page,
click Close.
On the taskbar, click Start,
and then click Control
Panel.
In Control
Panel, click Programs
and Features, and then click Turn
Windows Features on or off.
Expand Internet
Information Services, then World
Wide Web Services, then Health
and Diagnostics.
Select Tracing,
and then click OK.
Open Internet
Information Services (IIS) Manager:
If you are using Windows Server 2012 or Windows Server 2012 R2:
On the taskbar, click Server
Manager, click Tools,
and then click Internet
Information Services (IIS) Manager.
If you are using Windows 8 or Windows 8.1:
Hold down the Windows key,
press the letter X,
and then click Control
Panel.
Click Administrative
Tools, and then double-click Internet
Information Services (IIS) Manager.
If you are using Windows Server 2008 or Windows Server 2008 R2:
On the taskbar, click Start,
point to Administrative
Tools, and then click Internet
Information Services (IIS) Manager.
If you are using Windows Vista or Windows 7:
On the taskbar, click Start,
and then click Control
Panel.
Double-click Administrative
Tools, and then double-click Internet
Information Services (IIS) Manager.
In the Connections pane,
select the server connection, site, application, or directory for which you want to configure failed request tracing.
In the Actions pane,
click Failed
Request Tracing...
In the Edit
Web Site Failed Request Tracing Settings dialog box, select the Enable check
box to enable tracing, leave the default value or type a new directory where you want to store failed request log files in the Directory box,
type the number of failed request trace files you want to store in the Maximum
number of trace files box, and then click OK.
Open Internet
Information Services (IIS) Manager:
If you are using Windows Server 2012 or Windows Server 2012 R2:
On the taskbar, click Server
Manager, click Tools,
and then click Internet
Information Services (IIS) Manager.
If you are using Windows 8 or Windows 8.1:
Hold down the Windows key,
press the letter X,
and then click Control
Panel.
Click Administrative
Tools, and then double-click Internet
Information Services (IIS) Manager.
If you are using Windows Server 2008 or Windows Server 2008 R2:
On the taskbar, click Start,
point to Administrative
Tools, and then click Internet
Information Services (IIS) Manager.
If you are using Windows Vista or Windows 7:
On the taskbar, click Start,
and then click Control
Panel.
Double-click Administrative
Tools, and then double-click Internet
Information Services (IIS) Manager.
In the Connections pane,
go to the connection, site, application, or directory for which you want to configure failed request tracing.
In the Home pane,
double-click Failed
Request Tracing Rules.
In the Actions pane,
click Add...
On the Specify
Content to Trace page of the Add
Failed Request Tracing Rule Wizard, select the content type you want to trace, and then click Next.
On the Define
Trace Conditions page, select the conditions you want to trace, and then click Next.
Trace conditions can include any combination of status codes, a time limit that a request should take, or the event severity. If you specify all conditions, the first condition that is met generates the failed request trace log file.
On the Select
Trace Providers page, select one or more of the trace providers under Providers.
On the Select
Trace Providers page, select one or more of the verbosity levels under Verbosity.
If you selected the ASPNET or WWW
Server trace provider in step 8, select one or more functional areas for the provider to trace under Areas of
the Select
Trace Providers page.
Click Finish.
You can configure the
at the server level in the ApplicationHost.config file or at the site level, application level, or URL level in the appropriate Web.config file.
None.
The following configuration example configures tracing at the server level in the ApplicationHost.config file. It sets tracing for all .aspx files, uses the
to set the ASPNET provider
and trace against all ASP.NET areas, which areInfrastructure, Module, Page and AppServices.
The sample also uses the verbosity attribute
to set the amount of information returned to the tracing file to warning.
Lastly, the sample uses the
to trace only requests that generate a HTTP 404 status code.
The following examples enable verbose failed request tracing for HTTP 500 errors in ASP.NET content on all requests to *.aspx pages.
Overview
The
<traceFailedRequests>element
allows you to configure failed request tracing for a Web site, application, or directory. This element can contain a collection of
<add>elements
that define tracing rules, each of which specifies the extension of the request URL to which the rule applies, the trace providers and areas to enable, and the conditions that cause this rule to log the events.
Compatibility
Version | Notes |
---|---|
IIS 8.5 | The <traceFailedRequests>element was not modified in IIS 8.5. |
IIS 8.0 | The <traceFailedRequests>element was not modified in IIS 8.0. |
IIS 7.5 | The <traceFailedRequests>element was not modified in IIS 7.5. |
IIS 7.0 | The <traceFailedRequests>element was introduced in IIS 7.0. |
IIS 6.0 | N/A |
Setup
After you finish the default installation of IIS 7 and later, you must install the tracing role service to use failed request tracing. After you install the role service, you still must enable failed request tracing at the site level, application level, ordirectory level.
WINDOWS SERVER 2012 OR WINDOWS SERVER 2012 R2
On the taskbar, click ServerManager.
In Server
Manager, click the Manage menu,
and then click Add
Roles and Features.
In the Add
Roles and Features wizard, click Next.
Select the installation type and click Next.
Select the destination server and click Next.
On the Server
Roles page, expand Web
Server (IIS), expand Web
Server, expand Health
and Diagnostics, and then select Tracing.
Click Next.
.
On the Select
features page, click Next.
On the Confirm
installation selections page, click Install.
On the Results page,
click Close.
WINDOWS 8 OR WINDOWS 8.1
On the Start screen,move the pointer all the way to the lower left corner, right-click the Start button,
and then clickControl
Panel.
In Control
Panel, click Programs
and Features, and then click Turn
Windows features on or off.
Expand Internet
Information Services, expand World
Wide Web Services, expand Health
and Diagnostics, and then select Tracing.
Click OK.
Click Close.
WINDOWS SERVER 2008 OR WINDOWS SERVER 2008 R2
On the taskbar, click Start,point to Administrative
Tools, and then click Server
Manager.
In the Server
Manager hierarchy pane, expand Roles,
and then click Web
Server (IIS).
In the Web
Server (IIS) pane, scroll to the Role
Services section, and then click Add
Role Services.
On the Select
Role Services page of the Add
Role Services Wizard, select Tracing,
and then click Next.
On the Confirm
Installation Selections page, click Install.
On the Results page,
click Close.
WINDOWS VISTA OR WINDOWS 7
On the taskbar, click Start,and then click Control
Panel.
In Control
Panel, click Programs
and Features, and then click Turn
Windows Features on or off.
Expand Internet
Information Services, then World
Wide Web Services, then Health
and Diagnostics.
Select Tracing,
and then click OK.
How To
HOW TO ENABLE TRACING
Open InternetInformation Services (IIS) Manager:
If you are using Windows Server 2012 or Windows Server 2012 R2:
On the taskbar, click Server
Manager, click Tools,
and then click Internet
Information Services (IIS) Manager.
If you are using Windows 8 or Windows 8.1:
Hold down the Windows key,
press the letter X,
and then click Control
Panel.
Click Administrative
Tools, and then double-click Internet
Information Services (IIS) Manager.
If you are using Windows Server 2008 or Windows Server 2008 R2:
On the taskbar, click Start,
point to Administrative
Tools, and then click Internet
Information Services (IIS) Manager.
If you are using Windows Vista or Windows 7:
On the taskbar, click Start,
and then click Control
Panel.
Double-click Administrative
Tools, and then double-click Internet
Information Services (IIS) Manager.
In the Connections pane,
select the server connection, site, application, or directory for which you want to configure failed request tracing.
In the Actions pane,
click Failed
Request Tracing...
In the Edit
Web Site Failed Request Tracing Settings dialog box, select the Enable check
box to enable tracing, leave the default value or type a new directory where you want to store failed request log files in the Directory box,
type the number of failed request trace files you want to store in the Maximum
number of trace files box, and then click OK.
HOW TO CONFIGURE FAILURE DEFINITIONS
Open InternetInformation Services (IIS) Manager:
If you are using Windows Server 2012 or Windows Server 2012 R2:
On the taskbar, click Server
Manager, click Tools,
and then click Internet
Information Services (IIS) Manager.
If you are using Windows 8 or Windows 8.1:
Hold down the Windows key,
press the letter X,
and then click Control
Panel.
Click Administrative
Tools, and then double-click Internet
Information Services (IIS) Manager.
If you are using Windows Server 2008 or Windows Server 2008 R2:
On the taskbar, click Start,
point to Administrative
Tools, and then click Internet
Information Services (IIS) Manager.
If you are using Windows Vista or Windows 7:
On the taskbar, click Start,
and then click Control
Panel.
Double-click Administrative
Tools, and then double-click Internet
Information Services (IIS) Manager.
In the Connections pane,
go to the connection, site, application, or directory for which you want to configure failed request tracing.
In the Home pane,
double-click Failed
Request Tracing Rules.
In the Actions pane,
click Add...
On the Specify
Content to Trace page of the Add
Failed Request Tracing Rule Wizard, select the content type you want to trace, and then click Next.
On the Define
Trace Conditions page, select the conditions you want to trace, and then click Next.
Trace conditions can include any combination of status codes, a time limit that a request should take, or the event severity. If you specify all conditions, the first condition that is met generates the failed request trace log file.
On the Select
Trace Providers page, select one or more of the trace providers under Providers.
On the Select
Trace Providers page, select one or more of the verbosity levels under Verbosity.
If you selected the ASPNET or WWW
Server trace provider in step 8, select one or more functional areas for the provider to trace under Areas of
the Select
Trace Providers page.
Click Finish.
Configuration
You can configure the <traceFailedRequests>element
at the server level in the ApplicationHost.config file or at the site level, application level, or URL level in the appropriate Web.config file.
ATTRIBUTES
None.
CHILD ELEMENTS
Element | Description |
---|---|
add | Optional element. Adds a path to the collection of path definitions. |
remove | Optional element. Removes a reference to a path from the path definitions collection. |
clear | Optional element. Removes all references to paths from the path definitions collection. |
CONFIGURATION SAMPLE
The following configuration example configures tracing at the server level in the ApplicationHost.config file. It sets tracing for all .aspx files, uses the <traceAreas>element
to set the ASPNET provider
and trace against all ASP.NET areas, which areInfrastructure, Module, Page and AppServices.
The sample also uses the verbosity attribute
to set the amount of information returned to the tracing file to warning.
Lastly, the sample uses the
<failureDefinitions>element
to trace only requests that generate a HTTP 404 status code.
<tracing> <traceFailedRequests> <add path="*.aspx"> <traceAreas> <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Warning" /> </traceAreas> <failureDefinitions statusCodes="404" /> </add> </traceFailedRequests> </tracing>
Sample Code
The following examples enable verbose failed request tracing for HTTP 500 errors in ASP.NET content on all requests to *.aspx pages.
APPCMD.EXE
appcmd.exe set config "Contoso" -section:system.webServer/tracing/traceFailedRequests /+"[path='*.aspx']" appcmd.exe set config "Contoso" -section:system.webServer/tracing/traceFailedRequests /+"[path='*.aspx'].traceAreas.[provider='ASPNET',areas='Infrastructure,Module,Page,AppServices',verbosity='Verbose']" appcmd.exe set config "Contoso" -section:system.webServer/tracing/traceFailedRequests /[path='*.aspx'].failureDefinitions.statusCodes:"500"
C#
using System; using System.Text; using Microsoft.Web.Administration; internal static class Sample { private static void Main() { using (ServerManager serverManager = new ServerManager()) { Configuration config = serverManager.GetWebConfiguration("Contoso"); ConfigurationSection traceFailedRequestsSection = config.GetSection("system.webServer/tracing/traceFailedRequests"); ConfigurationElementCollection traceFailedRequestsCollection = traceFailedRequestsSection.GetCollection(); ConfigurationElement addElement = traceFailedRequestsCollection.CreateElement("add"); addElement["path"] = @"*.aspx"; ConfigurationElementCollection traceAreasCollection = addElement.GetCollection("traceAreas"); ConfigurationElement addElement1 = traceAreasCollection.CreateElement("add"); addElement1["provider"] = @"ASPNET"; addElement1["areas"] = @"Infrastructure,Module,Page,AppServices"; addElement1["verbosity"] = @"Verbose"; traceAreasCollection.Add(addElement1); ConfigurationElement failureDefinitionsElement = addElement.GetChildElement("failureDefinitions"); failureDefinitionsElement["statusCodes"] = @"500"; traceFailedRequestsCollection.Add(addElement); serverManager.CommitChanges(); } } }
VB.NET
Imports System Imports System.Text Imports Microsoft.Web.Administration Module Sample Sub Main() Dim serverManager As ServerManager = New ServerManager Dim config As Configuration = serverManager.GetWebConfiguration("Contoso") Dim traceFailedRequestsSection As ConfigurationSection = config.GetSection("system.webServer/tracing/traceFailedRequests") Dim traceFailedRequestsCollection As ConfigurationElementCollection = traceFailedRequestsSection.GetCollection Dim addElement As ConfigurationElement = traceFailedRequestsCollection.CreateElement("add") addElement("path") = "*.aspx" Dim traceAreasCollection As ConfigurationElementCollection = addElement.GetCollection("traceAreas") Dim addElement1 As ConfigurationElement = traceAreasCollection.CreateElement("add") addElement1("provider") = "ASPNET" addElement1("areas") = "Infrastructure,Module,Page,AppServices" addElement1("verbosity") = "Verbose" traceAreasCollection.Add(addElement1) Dim failureDefinitionsElement As ConfigurationElement = addElement.GetChildElement("failureDefinitions") failureDefinitionsElement("statusCodes") = "500" traceFailedRequestsCollection.Add(addElement) serverManager.CommitChanges() End Sub End Module
JAVASCRIPT
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager'); adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Contoso"; var traceFailedRequestsSection = adminManager.GetAdminSection("system.webServer/tracing/traceFailedRequests", "MACHINE/WEBROOT/APPHOST/Contoso"); var traceFailedRequestsCollection = traceFailedRequestsSection.Collection; var addElement = traceFailedRequestsCollection.CreateNewElement("add"); addElement.Properties.Item("path").Value = "*.aspx"; var traceAreasCollection = addElement.ChildElements.Item("traceAreas").Collection; var addElement1 = traceAreasCollection.CreateNewElement("add"); addElement1.Properties.Item("provider").Value = "ASPNET"; addElement1.Properties.Item("areas").Value = "Infrastructure,Module,Page,AppServices"; addElement1.Properties.Item("verbosity").Value = "Verbose"; traceAreasCollection.AddElement(addElement1); var failureDefinitionsElement = addElement.ChildElements.Item("failureDefinitions"); failureDefinitionsElement.Properties.Item("statusCodes").Value = "500"; traceFailedRequestsCollection.AddElement(addElement); adminManager.CommitChanges();
VBSCRIPT
Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager") adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Contoso" Set traceFailedRequestsSection = adminManager.GetAdminSection("system.webServer/tracing/traceFailedRequests", "MACHINE/WEBROOT/APPHOST/Contoso") Set traceFailedRequestsCollection = traceFailedRequestsSection.Collection Set addElement = traceFailedRequestsCollection.CreateNewElement("add") addElement.Properties.Item("path").Value = "*.aspx" Set traceAreasCollection = addElement.ChildElements.Item("traceAreas").Collection Set addElement1 = traceAreasCollection.CreateNewElement("add") addElement1.Properties.Item("provider").Value = "ASPNET" addElement1.Properties.Item("areas").Value = "Infrastructure,Module,Page,AppServices" addElement1.Properties.Item("verbosity").Value = "Verbose" traceAreasCollection.AddElement addElement1 Set failureDefinitionsElement = addElement.ChildElements.Item("failureDefinitions") failureDefinitionsElement.Properties.Item("statusCodes").Value = "500" traceFailedRequestsCollection.AddElement addElement adminManager.CommitChanges()
相关文章推荐
- 如何点击运动中的Button(控件)
- [解决]Error:failed to find Build Tools revision
- UESTC 1019 SSRaligun酱的魔法符文 用记忆实际区间最左min1最右max1来减小时间复
- IOS UITableView (三)
- iOS运用runtime全局修改UILabel的默认字体
- poj3481 Double Queue
- Vivado AXI Reference Guide 阅读笔记
- UIView的概念与使用
- IOS UITableView (二)
- pcduino 无法打开usb摄像头。
- PMON failed to acquire latch, see PMON dump
- UIAlertViewController 2
- IOS UITableView
- Queue、BlockingQueue以及利用BlockingQueue实现生产者/消费者模型
- UI基础_UIImage
- 【干货】jsMind思维导图整合Easyui的右键菜单
- Unique Binary Search Trees
- iOS-自定义 UITabBarController
- iOS-自定义 UITabBarController
- GCD 与 NSOperationQueue