2

The Log4net FAQ says that log4net is thread-safe:

Question: Is log4net thread-safe?

Answer: Yes, log4net is thread-safe.

However, the manual for the AdoNetAppender class says the following:

Instance members are not guaranteed to be thread-safe.

My guess is that log4net is not thread-safe. I'm using this class to log into a database, and manually flushing the appended data from time to time. I see that some records are duplicated.

Looking at the code, it appears to me that the base class BufferingAppenderSkeleton locks the object for the flush(), however the function SendFromBuffer() which is eventually called can be invoked from other places without lock (for instance Append()). Therefore, it appears that the class is not thread-safe.

So should I conclude that the class is not thread-safe, however the usage in log4net makes it so?

Chad Nouis
  • 6,861
  • 1
  • 27
  • 28
AWS User
  • 101
  • 5

0 Answers0