如何记录 asp.net 页面生成时间

发布于 2024-12-11 13:56:27 字数 285 浏览 0 评论 0原文

我收到用户的投诉,称我负责支持的 ASP.NET Web 应用程序间歇性缓慢。如何记录页面生成时间数据,以便我可以量化是否是这种情况,如果是,哪些页面速度慢,以及一天中的什么时间。我不希望向用户显示这些信息,我只想将其记录在每个页面请求的某个地方,然后我将每天或每周查看日志并将其导入数据库或 Excel 中进行操作。

我查看了一些讨论打开跟踪的问题,但我无法确定跟踪数据的记录位置。

额外的一点是不需要更改代码,因为这是一个生产系统,我希望能够使用开箱即用提供的任何性能计数器和现有日志功能,而不是在可能的情况下自行推出。

I'm getting complaints from users that an ASP.NET web application I'm responsible for supporting is intermittently slow. How can log page generation time data so that I can quantify if this is the case, and if so which pages are slow, and what time of day. I don't want this information displayed to the user, I just want to log it somewhere for every page request and then I'll take a look at the logs on a daily or weekly basis and import them into a database or excel for manipulation.

I looked at some SO questions that discuss turning on tracing but I haven't been able to determine where that trace data gets logged.

Extra points for being something that doesn't require a code change as this is a production system and I would like to be able to use whatever performance counters and existing log functionality that is provided out of the box instead of rolling my own if possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月棠 2024-12-18 13:56:28

IIS 日志,最简单的开始,也需要最少的更改。确保在 IIS 管理器中勾选了“所用时间”。日志的默认位置将位于 %SystemDrive%\inetpub\logs\LogFiles(您需要识别您的 Web 服务器实例)。所用时间字段(以毫秒为单位)将附加到请求日志行。您可以将其导入 Excel,或使用 IIS 日志分析器等工具。

web.config 中的 Trace.axd,确保启用跟踪。

<system.web>
<trace enabled="true" localOnly="false" requestLimit="50" />
</system.web>

导航到应用程序,在那里做一些事情。然后转到 http://yourhost/yourApp/Trace.axd,它将显示从一开始的计时每个页面的事件。可以从那里收集一些信息。但并不多。

IIS Logs, Easiest thing to start with, also requiring least changes. Make sure that "Time Taken" is ticked in the IIS Manager. Default location of the logs will be somewhere here %SystemDrive%\inetpub\logs\LogFiles, (you'll need to identify your web server instance). The time taken field in milliseconds will be appended to request log line. You can import it to excel, or use tools like IIS Log analyzer.

Trace.axd in web.config, make sure the trace is enabled.

<system.web>
<trace enabled="true" localOnly="false" requestLimit="50" />
</system.web>

navigate to application, do something there. then go to http://yourhost/yourApp/Trace.axd, it will display timings from the start for each page events. Some information can be gathered from there. But it's not much.

叶落知秋 2024-12-18 13:56:28

您可以将 httpModule 与事件一起使用:
你应该创建一个 dll 并通过 webconfig 将其注册到 httpmodule 部分。
现在您应该在 ProcessRequest 和 PostREquestHandlerExecute 中放置一个秒表。然后你就会拥有全部时间。
您也可以使用跟踪,但它位于页面本身的内部......并绕过一些初始化事件......

ProcessRequest
..
..
..
page things...
..
..
..
PostREquestHandlerExecute

you can use the httpModule with the events :
you should make a dll and via webconfig -register it with the httpmodule Section.
now you should put a stop watch in the ProcessRequest and PostREquestHandlerExecute. and then youll have the overall time.
also you can use trace but its internal to the page itself.... and bypass some of initialize events...

ProcessRequest
..
..
..
page things...
..
..
..
PostREquestHandlerExecute
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文