Hi Brad, I asked some similar questions awhile back. The response I received from Nicko Cadell was: > The appenders that derive from AppenderSkeleton are thread safe for multithearded operation > when used withing the log4net framework. Another quote from him:
> How log4net implements this with regards to individual appenders is > not really important. The docs for the RollingFileAppender are > correct, the members of the type are not thread safe, but this is not > relevant unless you want to programmatically access the appender directly from you code. > During logging the appender's base class (AppenderSkeleton) ensures > serialisation of appending of logging events. For a FileAppender in multithreaded operation, I believe you will want to use a different locking model: <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> Hope this helps, Bill Sorensen Objects and Infrastructure Integrated DNA Technologies ________________________________ From: Brad Ivey [mailto:[EMAIL PROTECTED] Sent: Monday, March 05, 2007 7:07 PM To: [email protected] Subject: Programmatic config and thread safety I am currently designing the logging componet of a larger software project (C#, .NET 2.0, Log4Net 1.2.10). It's basically a custom logging API which uses Log4Net behind the scenes. The project involves multiple processes, some of which have multiple threads. It is also a requirement that all configuration must be done programmatically rather than with a config file ( i.e. defining the name of log files at runtime). We initially chose Log4Net because it says right in the FAQ that it's thread safe, and I think we just took that at face value. Once I started digging into programmatic configuration API, however, I saw that all the useful classes like Hierarchy and Logger, all the Appenders, etc. seem to be labelled as NOT thread safe. This leaves me with a few questions that I haven't been able to find answers to in the mailing list archives or docs. First, under what circumstances IS Log4Net thread-safe? My understanding is that it's safe as long as I don't directly access classes like Logger in my code and instead use the "normal" XML file config methods, is that correct? And if so, is there any reason that I can't just write my own thread sync code around the Log4Net calls to ensure that no two threads are making them simultaneously?
