none
Log4Net in Parallel Context RRS feed

  • Question

  • Hi,

    I've a windows service and inside i implemented a task parallel execution. i am using Log4net(AdoNetAppender) to log error+info to database. i want to log all things in each loop(task). After writing log in each loop i need to close the appender of each loop and close the connection of each AdoNetAppender. How can i define appender for each loop and call the close method of each appender. please let me know.

    public class LogHandler
    {
       private ILog _logNet = LogManager.GetLogger(typeof(LogHandler));
    }

    it will probably return the same instance of type ILog, but we need different instance,right?

    public void write()
    {
      var logAppender = _logNet.Logger.Repository.GetAppenders()[0];
      //......
      //write in database using AdoNetAppender
      //......
      logAppenders.Close();
    }

    How to get the specific appender.and close the connection etc?

    Please let me know.it's urgent

    Best regards

    sabbir


    Wednesday, August 24, 2016 2:36 AM

Answers