记录 IIS 应用程序池启动、关闭和回收

发布于 2024-10-06 18:31:39 字数 407 浏览 0 评论 0原文

我的应用程序正在共享托管环境中运行。我的应用程序确实有一个专用的应用程序池。我一直在对第一次访问和预编译性能进行一些测试,并一直在跟踪我的应用程序何时启动和关闭。

在我的 Global.asax 中,我在 Application_Start 和 Application_End 中有一些日志记录代码。我通常可以从日志中看到应用程序空闲并关闭时,然后有人访问并且它会重新启动。

但是,我也看到过这样的情况:记录一次关闭,然后大约 13 分钟后再次关闭;中间没有启动。

我还看到连续出现两家初创公司的情况。我猜这些可能是回收,但为什么没有关闭日志条目呢?

我真正想知道是否有更好的方法来跟踪我的应用程序何时启动、何时关闭以及是否由于空闲池或回收而关闭。我无权访问 Windows 事件日志,因此如果可能的话,我需要从我的应用程序执行此操作。

My application is running in a shared hosting environment. I do have a dedicated App Pool for my app. I've been doing some testing with 1st visits and precompile performance and have been tracking when my application starts up and shuts down.

In my Global.asax I have some logging code in Application_Start and Application_End. I can see from my logs generally when the application is idle and shuts down, then someone visits and it starts back up.

But, I also see cases where a shutdown is logged and then followed by another shutdown about 13 minutes later; without a startup in the middle.

I also see instances where there are two Startups in a row. I'm guessing these might be a recycle, but why wouldn't there be a shutdown log entry?

What I'd really like to know if there is a better way to track when my application starts, when it shuts down and if it is shutdown due to an idle pool, or from a recycle. I don't have access to the Windows Event Log so I need to do this from my app if possible.

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

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

发布评论

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

评论(1

公布 2024-10-13 18:31:39

Application_Start 和 Application_End 在应用程序的每个生命周期中只应调用一次,MSDN 确认了这一点。

在不了解您的托管环境的情况下,您的 Web 主机可能会在多个工作池或 IIS 实例上运行您的网站。您的应用程序池也可能由于池中的其他应用程序而意外崩溃。

如果无法访问事件日志或基本 Web 主机控制面板以外的任何内容,最好的日志记录方式就是您现在正在执行的操作,即使用 Global.ASAX

Application_Start and Application_End should only be called once per lifetime in your application, MSDN confirms this.

Without knowing your hosting environment it is possible that your web host is running your website over multiple worker pools or IIS instances. Your application pool could also be unexpectedly crashing due to other apps in the pool.

Without access to the Event Log or anything other than a basic web host control panel your best way of logging is what you're doing now, using Global.ASAX

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