I wish to have a single WAR file that will work in different environments (like dev, ci and prod) and spring environments largely cater to our use cases. log4j per environment is one of the outstanding items. As suggested in other answers, we can have a log4j configuration per environment - but there is a lot of repetition in the files for each of the environments and the only kind of things that differ are minor properties like toAddress of SMTPAppender, etc.. Is there an easy way by which one can use a template-like log4j configuration file and have the parts that differ for each environment replaced at runtime? Maven will not work here because it will cause compile time choice.
One solution I can think of is to extend the Log4jConfigurer to read some environment variables viz. map of template key-value pairs and replace the template variables in the template file with the actual values before passing it down to the DOMConfigurator. Just wanted to check if there are simpler ways of doing it or if I am barking up a wrong tree from a best practices point of view.
Thanks in advance!