IIS/ASP.net error for failed request tracing: “a failed request trace for this content already exists”

天大地大妈咪最大 提交于 2019-12-06 05:07:46

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4474843/iis-asp-net-error-for-failed-request-tracing-a-failed-request-trace-for-this-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!