.net - How to automatically call a method in a static class on application start up and close down? -
I am writing a static class for logging in my advanced solution. There are several components that are used in console applications, ASP.NET Applications etc. ...
For logging to work, some initial startup configurations need to be done before using it, and nothing is cleared when each application ends goes.
Is there a way in which netlog () is initially (andlog) and the FinnishLog () method without having to call each application in the solution? Or maybe it's a different way of looking at it altogether?
I was thinking of using a lock in each log () method to start the logging class, although both potential potential complexity in the performance scares me.
You can use a type initializer (like a fixed constructor) for startup side things - When you first use a class, it will be called automatically.
Shutdown is difficult to detect ... there may be more enough for you ... just subscribe events and accordingly feedback.
Comments
Post a Comment