When my log4cplus configuration file changes, I'd like to reload my logging settings -- reinitialize log4cplus. What's the right way to do it?
I've tried this, but it seems to disable logging completely:
1 Logger::getDefaultHeirarchy.resetConfiguration();
2 log4cplus::helpers::Properties props("logging.properties");
3 props.setProperty("PID", pidstr);
4 PropertyConfigurator propcfg(props, Logger::getDefaultHeirarchy(), PropertyConfigurator::fShadowEnvironment):
5 propcfg.configure();
On the other hand, the follow seems to work for changing log levels, but I don't know if it is complete:
LoggerList loggers = Logger::getRoot()::getCurrentLoggers();
for (LoggerList::iterator it = loggers.begin(); it != loggers.end(); ++it)
{
it->setLogLevel(NOT_SET_LOG_LEVEL);
it->shutdown();
}
followed by lines 2 through 5 above
Thank you.
Never mind. Another person made a code change that broke my reload. Logger::getDefaultHeirarchy.resetConfiguration() does what I expect.
Ticket moved from /p/log4cplus/support-requests/26/