Nicko, AppenderSkeleton's IAppender.DoAppender method contains this
code and comment:

 public void DoAppend(LoggingEvent loggingEvent) 
 {              

  // This lock is absolutely critical for correct formatting
  // of the message in a multi-threaded environment.  Without
  // this, the message may be broken up into elements from
  // multiple thread contexts (like get the wrong thread ID).
  
  lock(this)
  {
   // [snip]
  }
 }

FastDbAppender contains this code:

 public virtual void DoAppend(LoggingEvent loggingEvent)
 {
  using(IDbConnection connection = GetConnection())
  {
   // Open the connection for each event, this takes advantage
   // of the builtin connection pooling
   connection.Open();
 
   using(IDbCommand command = connection.CreateCommand())
   {
    InitializeCommand(command);
 
    SetCommandValues(command, loggingEvent);
    command.ExecuteNonQuery();
   }
  }
 }

Is it necessary for FastDbAppender to have a lock statement around that code?

Reply via email to