Submitted by: Michael Locher <locher@iam.unibe.ch> Hi all I had to find a way to provide a user dependent configuration file for my java webstart application. the stright forward way to do so, is to handle property substitution in the LogManager initalisation. webstart users can provide something like this: <property name="log4j.configuration" value="file:// ${user.home}/log4j.properties" /> the substitiution code was already there, so the patch is quite small. one new method in OptionConverter and 3 renamings in LogManager. In what format do you expect the patch? I have included a diff against CVS HEAD below. Regards Michael Locher ##################################################################### diff -r1.37 OptionConverter.java 20a21 > // Michael Locher (locher@iam.unibe.ch) 98a100,120 > /** > Very similar to <code>System.getProperty</code> except > that the {@link SecurityException} is hidden and substitutions are perfor med. > > @param key The key to search for. > @param def The default value to return. > @return the string value of the system property with applied substitution s, or the default > value if there is no property with that key. > */ > public > static > String getSubstitutedSystemProperty(String key, String def) { > try { > Properties systemProperties = System.getProperties(); > return OptionConverter.substVars(OptionConverter.getSystemProperty(key , def), > System.getProperties()); > } catch(Throwable e) { // MS-Java throws com.ms.security.SecurityExcepti onEx > LogLog.debug("Was not allowed to read system properties."); > return def; > } > } ##################################################################### diff -r1.9 LogManager.java 78,79c78,79 < String override =OptionConverter.getSystemProperty(DEFAULT_INIT_OVERRIDE_K EY, < null); --- > String override =OptionConverter.getSubstitutedSystemProperty(DEFAULT_INIT _OVERRIDE_KEY, > null); 85c85 < String configurationOptionStr = OptionConverter.getSystemProperty( --- > String configurationOptionStr = OptionConverter.getSubstitutedSystemProp erty( 89c89 < String configuratorClassName = OptionConverter.getSystemProperty( --- > String configuratorClassName = OptionConverter.getSubstitutedSystemPrope rty( #####################################################################
I can see the value of it and don't see another way to perform the substitution in Webstart, however I'm uncomfortable making the change this late in log4j 1.2's life. I'd recommend specifying log4j.configuratorClass and providing a class that evaluates user.home to before delegating to one of the other configurators.
*** Bug 25107 has been marked as a duplicate of this bug. ***