From: Emiliano M. <emi...@te...> - 2002-08-01 19:31:21
|
Hi: I'd like the idea, and i have done. This is a a Pthread implementation. I've tested with a multithreaded program that i'm developing and seems to be ok, i expect it's ok with the philosofpy of log4cpp. Any suggestion or thing you think must be changed, tell me please. I expect new version be soon released. Regards, Emiliano Martín Bastiaan Bakker wrote: >Hi Emiliano, > >log4cpp 0.2.x does not explicitly support multithreading. >But with some restrictions it still can be used in a multithreading >environment: >* don't change your logging configuration when you have multiple threads >running. In most cases you'll setup your Category hierarchy before the >application starts logging anyway, so this is not a large problem. Calls >to setPriority() are still permitted. >* The append function must be atomic. Log4cpp's appenders have been >written in a way that requires only 1 call to the underlying system to >write a log message (i.e. a single write() for the FileAppender). If >your OS handles this atomically, the logfile will be OK. Otherwise you >could end up with intertwined log messages. The latter appears to be the >case at least with OstreamAppender on Win32 platforms. > >If you want to have full MT support, you'll be happy to know that as of >version 0.3.0 log4cpp includes code for multithreading. Currently >(release 0.3.2rc1) it supports Omnithreads and Win32 threads, but >support for POSIX threads should not be too difficult to add: it >requires an adapter implementation for a simple Mutex, ScopedLock and >ThreadLocalData. You're very welcome to help in this area, if you like. > >Regards, > >Bastiaan Bakker >LifeLine Networks bv > > >On Tue, 2002-06-18 at 18:05, Emiliano Martin wrote: > > >>Hi: >> >>I've read log4ccp does not suppport multithreading, can i do something >>like this to assure atomic access¿¿ >>or it's very restrictive?? (or stupid) >> >> >>void Category::_logUnconditionally(Priority::Value priority, >> const char* format, >> va_list arguments) throw() { >> OstringStream messageBuffer; >> >> pthread_mutex_lock(writeMutex); >> messageBuffer.vform(format, arguments); >> _logUnconditionally2(priority, messageBuffer.str()); >> pthread_mutex_unlock(writeMutex); >> } >> >>thanks in advance >> >> >>---------------------------------------------------------------------------- >> Bringing you mounds of caffeinated joy >> >>> http://thinkgeek.com/sf <<< >> >>_______________________________________________ >>Log4cpp-devel mailing list >>Log...@li... >>https://lists.sourceforge.net/lists/listinfo/log4cpp-devel >> >> > > > > > |