Posting a patch (
Basically, with this patch, we can append default value for a variable after the delimiter (the default delimiter is ':-'. The delimiter is customizable. See StrSubstitutor's setters).
The basic usages are shown and tested in the following unit tests:
- StrSubstitutorTest.java and XMLLoggerPropsTest.java
Also, RoutingAppenderWithJndiTest has been improved to show another default value setting example. This example can be used in the scenario where you want to leave log files per each web application by setting different JNDI context variable in each web application. Because we can use the JNDI context variable with default value, we don't have to even define multiple routes in this kind of use cases, but we can define single route with the variable and default value to leave separate logs for each web application.
By the way, the log4 configuration (log4j-loggerprops.xml) for XMLLoggerPropsTest.java also has a (global) property as well which have been used and is still working to define a default value.
The default value can be defined by either (global) property or inline default value after the delimiter.
If you have both (global) property and inline default value to specify default value for a variable, then the (global) property has precedence currently because the (global) property is used in StrLookup. The precedence order might be debatable later, but this seems okay to me for now.
Please review the patch.