I am trying to add Failed Request Tracing to my IIS 7/ASP.NET server.
First, I create failed request tracing for "all content, error codes 400-999
" because want to save all errors.
Then, I try to create a trace for "all content, time: 5 seconds
" because I want to trace all "long" requests. However, IIS 7 gives me an error: "A failed request trace for this content already exists".
How can I add this second trace for all content that takes > 5 seconds?
In your web.config
the Failed Request Tracing config looks something like:
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure, etc" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication, etc" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="400-999" />
</add>
</traceFailedRequests>
</tracing>
The attribute path
defines the content type i.e. the options in the first page of the Add FRT wizard (*, *.aspx, *.asp, Custom).
If you examine the schema for the system.webServer/tracing/traceFailedRequests
section in applicationHost.config
(located in %systemroot%\System32\inetsrv\
config\schema\IIS_schema.xml
you'll find the following constraints:
The failed request path must be unique:
<attribute name="path" type="string" isUniqueKey ="true" />
Within a path each provider (ASP, ASPNET, ISAPI Extension etc) must be unique:
<attribute name="provider" type="string" required="true" isUniqueKey="true" />
If you added another trace rule to trace the same content (*) but specifying timeTaken
then you'd be trying to add:
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure, etc" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication, etc" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="400-999" />
</add>
This of course conflicts with the rules in the schema which say that the path must be unique.
However what you can do is specify specific content that you want to trace when the timeTaken
is >= to 5 seconds.
For example:
<add path="*.aspx">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure, etc" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication, etc" verbosity="Verbose" />
</traceAreas>
<failureDefinitions timeTaken="00:00:05" statusCodes="400-999" />
</add>
<add path="*.asp">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure, etc" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication, etc" verbosity="Verbose" />
</traceAreas>
<failureDefinitions timeTaken="00:00:05" statusCodes="400-999" />
</add>
<add path="*.asmx">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure, etc" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication, etc" verbosity="Verbose" />
</traceAreas>
<failureDefinitions timeTaken="00:00:05" statusCodes="400-999" />
</add>
Not as convenient as just being able to do a wildcard but it is a workaround.