From: Václav H. <v.h...@sh...> - 2009-06-02 20:17:44
|
Koller, Georg wrote, On 2.6.2009 17:19: > Sorry, I forgot to add a few lines. > Here is the corrected code. > > What I did to see the error: > 1. Start application. > 2. Modify logger.properties. > 3. I would expect the application to quit after 20 seconds, but it never quits. I have identified some problems with the threading code and the ConfigureAndWatchThread itself. I think I have fixed at least one related to the life time of the watch dog thread object. To get it check out the code from <https://log4cplus.svn.sourceforge.net/svnroot/log4cplus/branches/PRODUCTION_1_0_x/log4cplus>. > > > #include <log4cplus/logger.h> > #include <log4cplus/configurator.h> > > #include <unistd.h> > > using namespace log4cplus; > > int > main > (int argc, char* argv []) > { > ConfigureAndWatchThread configureThread(LOG4CPLUS_TEXT("logger.properties"), 5 * 1000); To work around the problems in the log4cplus code, try the following instead: ConfigureAndWatchThread * configureThread = new ConfigureAndWatchThread(LOG4CPLUS_TEXT("logger.properties"), 5 * 1000); > > Logger log1 = Logger::getInstance("test.log_1"); > > LOG4CPLUS_FATAL(log1,"fatal message"); > > for (int i=0; i<20; i++) > { > sleep(1); > } delete configureThread; sleep (5 * 1000 + 1000); The problem here is that right now there is no way how to reliably wait for the watch dog thread to exit before exiting main(). > } -- VH |