2013-04-24 69 views
0

我有一個配置功能問題。 我想重新加載我的配置文件,當我點擊一個按鈕。log4cxx configureandwatch沒有影響?

我調用該函數

std::string filepath = "../../configurationfile.txt" 
log4cxx::PropertyConfigurator::configureAndWatch(log4cxx::File(filepath)); 

我試試這一個了:

log4cxx::PropertyConfigurator::configure(log4cxx::File(filepath)); 

但該文件後60第二個是唯一的重新加載。

你有什麼想法如何強制重新加載文件? 我第一次使用configureAndWatch函數進行配置。

感謝您的幫助。

回答

1

我不知道你是否需要這個問題的幫助了,但我會繼續並回答這個問題。

configureAndWatch()通常用於產生一個線程,該線程將定期檢查配置文件的變化。默認延遲爲60秒,您可以使用此

int delay_in_milliseconds = /* Small delay value */ 
log4cxx::PropertyConfigurator::configure(log4cxx::File(filepath), delay_in_milliseconds); 

然而修改這個值,我會建議不要因爲不必要的檢查,這將產生這樣的技術。相反,嘗試使用與由

PropertyConfigurator.configure(filepath); 

原因是,與配置()調用現有的配置不會被清零,也立即復位後

LogManager.resetConfiguration(); 

隨後調用按鈕關聯的獨立功能。雖然,我還沒有嘗試過,但我相信調用resetConfiguration()函數應該可以在當時應用更改。