Is there a way to know if my website got down due to Application Pool Recycle or Idle-Timeout?
The idea is register in a log file what caused website shutdown, my global.asax already register a shutdown at Application_End, and would like register when down due
AppPool Recycle or Idle-Timeout.
As far Enum covers all AppDomain Shutdown Reason, there is no specific AppPool Recycle or Idle-Timeout, in my tests found that any change in AppPool (config values or state) causes return ShutdownReason = HostingEnvironment
There is an application pool shutdown time limit in iis. Let's say it's 60 seconds and in shared hosting environment there is an application pool memory limit. Your application pool reaches this limit and iis tells the application pool to finish all
the work with current requests. If all the requests finish processing before 60 seconds is passed, application_end will trigger and application pool will gracefully shut itself down. However if 60 seconds pass and requests are still being processed, IIS gets
upset and kills the app pool. This time no application_end would trigger. Similarly, no error event handler would be triggered.
So, if you want to check the Application Pool recycle log, I suggest you could refer to the following articles to enable Application Pool recycle logging in IIS and find the logs.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
466 Points
351 Posts
How to Catch if App End due to Application Pool Recycle or Idle-Timeout on Application_End
Oct 11, 2018 11:40 PM|jzero|LINK
Is there a way to know if my website got down due to Application Pool Recycle or Idle-Timeout?
The idea is register in a log file what caused website shutdown, my global.asax already register a shutdown at Application_End, and would like register when down due
AppPool Recycle or Idle-Timeout.
Member
466 Points
351 Posts
Re: How to Catch if App End due to Application Pool Recycle or Idle-Timeout on Application_End
Oct 12, 2018 04:02 PM|jzero|LINK
After some more research, found what can fit my needs.
ApplicationShutdownReason Enum returned by System.Web.Hosting.HostingEnvironment.ShutdownReason
As far Enum covers all AppDomain Shutdown Reason, there is no specific AppPool Recycle or Idle-Timeout, in my tests found that any change in AppPool (config values or state) causes return ShutdownReason = HostingEnvironment
All-Star
45439 Points
7008 Posts
Microsoft
Re: How to Catch if App End due to Application Pool Recycle or Idle-Timeout on Application_End
Oct 15, 2018 06:18 AM|Zhi Lv - MSFT|LINK
Hi jzero,
Please refer to Jani's reply in this thread:
There is an application pool shutdown time limit in iis. Let's say it's 60 seconds and in shared hosting environment there is an application pool memory limit. Your application pool reaches this limit and iis tells the application pool to finish all the work with current requests. If all the requests finish processing before 60 seconds is passed, application_end will trigger and application pool will gracefully shut itself down. However if 60 seconds pass and requests are still being processed, IIS gets upset and kills the app pool. This time no application_end would trigger. Similarly, no error event handler would be triggered.
So, if you want to check the Application Pool recycle log, I suggest you could refer to the following articles to enable Application Pool recycle logging in IIS and find the logs.
How to enable Application Pool recycle logging.
Troubleshooting badly behaving IIS application pools
Best regards,
Dillion
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.