Hellom
Thank you for answering. I tried to use log4cxx::Level::getDebug().
It does not change my problem.
Aas my Stream and Logger are static,
static log4cxx::logstream stream;
static log4cxx::LoggerPtr logger;
I was wondering if I had to "lock" each time I wanted to send a logging message. It looks maybe like a beginners question, but I have no problem and no need to lock with std::cout.

regards.


Curt Arnold wrote:

Could you test using log4cxx::Level::getDebug() instead of log4cxx::Level::DEBUG? The static members DEBUG, INFO, etc are held over from 0.9.7 and log4j however non-local static member variables are problematic at best. I believe that DEBUG et al are marked as deprecated for that reason. I've been tempted to remove them entirely but that would probably warrant a vote to see how many people would be affected.


On Sep 14, 2006, at 4:02 AM, Salvati Marc wrote:

Hello,
I m using QThread and Log4cxx in a project. I created a simple class with static member to access logging anywhere in my soft. But when I m accessing from another thread I have some kind of random crash.
I tested without multithread and it work fine.
It s written in Log4cxx Faq that it s Thread safe. Am I wrong to use class static members or is there a bug in the thread safe functionnality? Is it problem to use QT Qthread with log4cxx?

Thank you for any kind help.
Best regards.

here the class declaration, initialization, and log sample.

//my class
class Log{
public :      static log4cxx::logstream stream;
   static log4cxx::LoggerPtr logger;
};

//initialization
log4cxx::LoggerPtr Log::logger(log4cxx::Logger::getLogger("Logger"));
log4cxx::logstream Log::stream(Log::logger, log4cxx::Level::DEBUG);

//logging sample
Log::stream<<"message"<<LOG4CXX_ENDMSG;







Reply via email to