0

I have a problem with the configure functionnality. I want to reload my configuration file when I click on a button.

I call the function

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

I try this one too:

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

But the file was only reloaded after 60 second.

Do you have any idea about how to forced the reload of the file ? The first time, i configure with the configureAndWatch function.

Thanks for your Help.

Shaina
  • 51
  • 5

1 Answers1

1

I don't know if you need help with this issue anymore, but I'll go ahead and answer this one anyway.

configureAndWatch() is usually used to spawn a thread that will periodically check the configuration file for changes. The default delay is of 60 seconds, you can modify that value by using this

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

However, I would recommend against such a technique because of unnecessary checks it will spawn. Instead try using a separate function associated with the button that calls upon

LogManager.resetConfiguration();

followed by a

PropertyConfigurator.configure(filepath);

The reason being that with the configure() call the existing configuration is not cleared nor reset immediately. Although, I haven't tried this but I believe calling the resetConfiguration() function should apply the changes at that instant.

One13
  • 11
  • 1