Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1589

Value nesting during property substitution

    XMLWordPrintableJSON

Details

    Description

      There is already a good description what "default value nesting" is: http://logback.qos.ch/manual/configuration.html#nestedSubst

      It is partially implemented in the log4j but it can still be improved.

      The problem appears if your default value is a variable too.

      Example: We have a glassfish project. Our log files must be placed to the <some_log_root>/application/logfiles directory on the server and if we work locally somewhere on our computer in the glassfish root <glassfish_root>/application/logfiles.

      The <some_log_root> and <glassfish_root> will be set as a java system variables:

      • <some_log_root>: -Dpath.configured.by.provisioning=/some/path/onserver/
      • <glassfish_root>: -Dcom.sun.aas.instanceRoot=/glassfishroot/application/logfiles

      At the moment we must have two log4j2.xml config files with different paths and it's not so great. So the target is to have only one config files that can handle thwo different paths.

      For example:

      ...
      <Properties>
             
         <Property name="path">${sys:path.configured.by.provisioning:-${sys:com.sun.aas.instanceRoot}}/application/logfiles/application/logfiles</Property>
             
      </Properties>
      ...
      

      If we deploy to the server and the value of path.configured.by.provisioning is the directory named 'master' the substitution result of StrSubstitutor is 'master}' then. But it works if we set this property as default value!:

      ${sys:com.sun.aas.instanceRoot:-${sys:path.configured.by.provisioning}}

      So the default value will be properly substituted, but not the first property. The value of the first property is always: <dirname>}

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dimarzio Dmitriy Neretin
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: