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"
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()