4

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.

svlasov
  • 9,923
  • 2
  • 38
  • 39
  • I use log4cxx and haven't yet nailed down the directory from which the properties file is normally loaded during development... the working directory seems to have an impact. – bvj Apr 01 '15 at 08:19

1 Answers1

3

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.

wilx
  • 17,697
  • 6
  • 59
  • 114