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 bu...@apache.org on 2002/11/07 14:57:00 UTC

DO NOT REPLY [Bug 14350] New: - Patch to substitute variables in the log4j.configuration property

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14350>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14350

Patch to substitute variables in the log4j.configuration property 

           Summary: Patch to substitute variables in the log4j.configuration
                    property
           Product: Log4j
           Version: 1.3alpha
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Other
        AssignedTo: log4j-dev@jakarta.apache.org
        ReportedBy: ceki@apache.org


Submitted by: Michael Locher <lo...@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(


#####################################################################

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