[ASP.NET揭密讀書筆記]應用程式跟蹤和監視

來源:互聯網
上載者:User

一、錯誤定向:
Two configuration settings affect how error information is displayed:

1.Custom errors mode— This setting enables or disables custom errors. When custom errors mode is enabled, errors on a page are hidden. This setting has three possible values: On, Off, and RemoteOnly.
When you are redirected to a page with custom errors, a query string variable is automatically passed to the error page. The query string variable, named aspxerrorpath, contains the path of the page that was originally requested.
2.Debug mode— When debug mode is enabled, additional information for debugging runtime errors is displayed.

例如如下的設定檔:
<configuration>
  <system.web>
    <customErrors mode="On" defaultRedirect="AppError.aspx">
      <error statusCode="404" redirect="NotFound.aspx" />
      <error statusCode="500" redirect="AppError.aspx" />
    </customErrors>
    <compilation debug="true" />
  </system.web>
</configuration>

二、使用效能計數器
1.Launch Performance Monitor by typing "perfmon" at a command prompt
2.Retrieving Performance Counters in an ASP.NET Page
You can use the classes from the System.Diagnostics namespace to work with performance counters within your application.
To retrieve an object that represents a particular performance counter, you need to supply the performance counter category name, performance counter name, and performance counter instance name. For example, the following statements create a counter that represents the Total Requests performance counter:
Dim objCounter As PerformanceCounter
objCounter = New PerformanceCounter( "ASP.NET Applications", "Requests Total", "__Total__" )

三、跟蹤(Trace)頁面執行
You can trace the execution of an ASP.NET page by using the trace attribute of the page directive. To enable tracing for a single ASP.NET page, include the following directive at the top of the page:<%@ Page Trace="True" %>。
When tracing is enabled for a page, trace information is automatically appended to the bottom of the page.
The trace information includes the following statistics:Request Details,Trace Information,Control Tree,Session State,Application State,Cookies Collection,Headers Collection,
Form Collection,QueryString Collection,Server Variables.

To add custom trace messages, use either the Trace.Warn or Trace.Write methods.
使用應用層級的Trace,You can use a special page, named trace.axd, to view trace information collected from all the pages in your application.
<configuration>
  <system.web>
  <trace
    enabled="true"
    requestLimit="50"
    pageOutput="false"
    traceMode="SortByTime"
    localOnly="true" />
  </system.web>
</configuration>
四、進程的監視
通過設定Machine.config中的某些項目可以修改aspnet_wp.exe的一些屬性,例如memoryLimit— The percentage of system memory that the ASP.NET process is allowed to consume. By default, this setting has the value 80, which stands for 80% of system memory. (memoryLimit refers to the percentage of physical memory, not the percentage of virtual memory.)。其他還有requestQueueLimit,shutdownTimeout。
還可以在程式中擷取當前進程的資訊You can use the ProcessModelInfo class to retrieve information about the ASP.NET process. The GetCurrentProcessInfo method returns information about the ASP.NET process currently executing, and the GetProcessInfoHistory method returns a history of ASP.NET processes.

 

 

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.