我有一个关于配置功能的问题。当我点击一个按钮时,我想重新加载我的配置文件。
我调用该函数
std::string filepath = "../../configurationfile.txt"
log4cxx::PropertyConfigurator::configureAndWatch(log4cxx::File(filepath));
我也试试这个:
log4cxx::PropertyConfigurator::configure(log4cxx::File(filepath));
但该文件仅在60秒后重新加载。
你知道如何强制重新加载文件吗?第一次,我使用configureAndWatch函数进行配置。
谢谢你的帮助。
发布于 2013-07-10 02:20:41
我不知道在这个问题上您是否还需要帮助,但我还是会继续回答这个问题。
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()函数应该会立即应用这些更改。
https://stackoverflow.com/questions/16185752
复制相似问题