I want to log inside a Windows service which will run in every 1 hour. I am using Parallel.ForEach
inside my Windows service. I am using AdoNetAppender to log in my sqlserver database.
ILog _log = LogManager.GetLogger(typeof(EmailJob));
The above line means, we are using a static instance to log in database, right? How connection is maintain in AdoNetAppender? When my Windows service complete first iteration and what will be the state of the connection of AdoNetAppender. Is it close at once or waiting for the Garbage collector to dispose? and when next iteration start, will it open a new connection?
As my Windows service is running always, if Garbage collector take long time to dispose the object, number of open connections will cross the limit of max open connections of SQL Server. I need to close my connection when iteration end and open the connection when iteration start. What to do?