none
WCF lifecycle events/methods RRS feed

  • Question

  • Hi All,

    First of all sorry if you think my question is not appropriate, but - despite the many articles in the topic - I did not find an acceptable solution for my problem until now.

    I want to use log4net to log my WCF service. As I used log4net the first time to log my WebApi services, I faced the problem that if I do not close the logging system on a proper way (by calling its' Shutdown() method), in the case of an application pool recycling it looses the log file and the newly started application pool is not able to initialize the logging and I will have no log entries. I started to use the Application_Start()/Application_End() methods in the Global.asax.cs for initialization/shutdown of logging and it works fine, I do not have this type of problem with this solution in WebApi projects.

    As I started to write WCF services (hosted on IIS), I tried to search for the lifecycle methods working on the same way (called once at the APPLICATION initialization and shutdown), I found many workarounds for initialization but nothing for shutdown. (I tried the same Global.asax.cs solution, but it works only for HTTP(S) endpoints and does not fire for NET.TCP endpoints.)

    So my question is: are there similar APPLICATION lifecycle methods for IIS hosted WCF services as the Application_Start()/Application_End() methods for webapps?

    Thanks in advance:

    Ferenc

    Wednesday, May 22, 2019 2:41 PM

All replies