user1731045
user1731045

Reputation: 69

log4cplus properties file changes are not being read runtime

Is there any configuration which helps in log4cplus picking dynamic changes? I am changing log4cplus properties on runtime and want log4cplus to pick those changes dynamically.

Upvotes: 4

Views: 580

Answers (1)

wilx
wilx

Reputation: 18238

There is the ConfigureAndWatchThread class which you can instantiate. It will spawn a thread which will watch for modification time changes on given configuration file. When it notices the modification time change into the future of the last recorded modification time, it will remove all the previously instantiated loggers and appenders, etc., and will reconfigure everything.

However, it is not very sophisticated and there is no defence against catching the configuration file change mid air while it is still being written by your editor. If this danger is not important for you, use it. Otherwise, I would suggest you build some sort of manual trigger into your software that will make it re-read the logging configuration only on the trigger.

Upvotes: 3

Related Questions