0

我想知道我是否可以跟踪它,因为如果这种情况经常发生,我想知道它的根本原因。是否有任何时间戳日志记录可用于在 IIS 中重新启动我的站点,如何以编程方式跟踪它?

谢谢大家。

4

2 回答 2

3

在 Global.asax 上

void Application_Start(object sender, EventArgs e) 

void Application_End(object sender, EventArgs e) 

在应用程序启动和结束时调用。您可以使用它们来记录它。现在要知道为什么您的池要重新启动,您可以简单地检查您的池的设置,您可能设置了很多原因,也许您设置了时间限制,也许是内存限制,也许是其他设置......您可以检查他们并改变他们。

于 2012-05-16T14:02:26.740 回答
2

您可以在 Global.asax Application_End 中记录应用程序重启的原因:

protected void Application_End(object sender, EventArgs e)
{
  HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);

  string shutDownMessage = "";

  if (runtime != null)
  {
    shutDownMessage = Environment.NewLine + "Shutdown: " +
                      (string)runtime.GetType().InvokeMember("_shutDownMessage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null) + 
                      Environment.NewLine + "Stack: " + Environment.NewLine +
                      (string)runtime.GetType().InvokeMember("_shutDownStack", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);
  }
}
于 2012-05-16T14:06:05.240 回答