我遇到configure functionnality的问题。 我想在单击按钮时重新加载配置文件。
我调用了函数
std::string filepath = "../../configurationfile.txt"
log4cxx::PropertyConfigurator::configureAndWatch(log4cxx::File(filepath));
我也尝试过这个:
log4cxx::PropertyConfigurator::configure(log4cxx::File(filepath));
但该文件仅在60秒后重新加载。
您对如何强制重新加载文件有任何想法吗? 第一次,我使用configureAndWatch函数进行配置。
感谢您的帮助。
答案 0 :(得分:1)
我不知道你是否需要这个问题的帮助,但无论如何我都会继续回答这个问题。
configureAndWatch()通常用于生成一个线程,该线程将定期检查配置文件中的更改。默认延迟为60秒,您可以使用此
修改该值int delay_in_milliseconds = /* Small delay value */
log4cxx::PropertyConfigurator::configure(log4cxx::File(filepath), delay_in_milliseconds);
但是,我建议不要使用这种技术,因为它会产生不必要的检查。而是尝试使用与调用
的按钮相关联的单独函数LogManager.resetConfiguration();
后跟
PropertyConfigurator.configure(filepath);
原因是使用configure()调用时,不会清除现有配置,也不会立即重置。虽然,我没有试过这个,但我相信调用resetConfiguration()函数应该在那一刻应用更改。