Logging with log4net stops when aspnet_wp is recycled
A collegue of mine just discovered this problem. The problem was that logging using log4net stops whenever the aspnet_wp process is recycled. The problem is caused by the way log4net and ASP.NET works.
First, whenever the aspnet_wp process has been idle for a while or has used more memory than it should (over 60% default), the process is recycled. This is done in a clever way so users should not be affected. A new aspnet_wp process is started in parallell with the old one, gradually taking over the workload by serving all new requests.
Second, log4net stops logging, even stops trying to log, as soon as it finds out that it can't write to the logfile. Essentially logging is then disabled.
These two facts together is causing logging to stop. When the second aspnet_wp process is started, it will try to log to the same file that the old aspnet_wp process is already logging to. The file will be locked by the old process, so log4net in the new process will detect that the file is not writeable, and disable logging.
No comments:
Post a Comment