If DOMConfigurator::configureAndWatch() called more than ones no XMLWatchdog thread is created.
This happens because when old xdog is deleted it removes task in its dtor, so old thread in ThreadUtility::priv_data::doPeriodicTasks() finishes since jobs list is empty. On the next configuration new thread isn't created in ThreadUtility::addPeriodicTask because the old thread is joinable, so code goes to m_priv->interrupt.notify_one(); which does nothing.
Minimal code example to see if the watcher is running:
#include <iostream>
#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/logmanager.h>
static auto logger = log4cxx::Logger::getLogger("MyApp");
int main()
{
log4cxx::xml::DOMConfigurator::configureAndWatch((std::string)"c:\\tmp\\log4cxx.xml");
int c = std::getchar();
while (c != 'q')
{
if (c == 'c')
{
std::cout << "configure\n";
log4cxx::xml::DOMConfigurator::configureAndWatch((std::string)"c:\\tmp\\log4cxx.xml");
}
c = std::getchar();
}
log4cxx::LogManager::shutdown();
return 0;
}
If
DOMConfigurator::configureAndWatch()called more than ones no XMLWatchdog thread is created.This happens because when old xdog is deleted it removes task in its dtor, so old thread in
ThreadUtility::priv_data::doPeriodicTasks()finishes since jobs list is empty. On the next configuration new thread isn't created inThreadUtility::addPeriodicTaskbecause the old thread is joinable, so code goes tom_priv->interrupt.notify_one();which does nothing.Minimal code example to see if the watcher is running: