You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Ceki Gülcü <ce...@qos.ch> on 2002/11/07 15:01:19 UTC

Re: Patch to substitute variables in the log4j.configuration property


Michael,

I created bug number 14350 so that we can remember to add this 
functionality. See
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14350

Many thanks for the patch.

At 14:42 07.11.2002 +0100, you wrote:
>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(
>
>#####################################################################
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>

--
Ceki

TCP implementations will follow a general principle of robustness: be
conservative in what you do, be liberal in what you accept from
others. -- Jon Postel, RFC 793



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>