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

Faulty placeholder substitution in config xml

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.8
    • Component/s: Lookups
    • Labels:
      None
    • Environment:

      JDK 8

      Description

      I'm using log4j 2.5 in a REST service.

      There I would like to use the placeholder substitution to allow configuration of the log location.

      I tried this:

      <Properties>
      <!-- sets the path for log4j logs:
      1. check whether java system property myapp.logs is set. If not:
      2. check whether the OS environment variable MYAPP_LOGS is set. If not:
      3. use logs dir in the current directory
      -->
      <Property name="logsPath">${sys:mypapp.logs:-${env:MYAPP_LOGS:-logs}}</Property>
      </Properties>
      

      This seems to work quite well with the exception, if myapp.logs is set, the path ends with "}". So if I set the system property "-Dmyapp.logs=foobar" it creates the directory "foobar}" and puts the logs into that. For the ENV substitution it works. It also works when NO placeholder nesting is performed. So I guess the problem has something todo with that.

      See: http://mail-archives.apache.org/mod_mbox/logging-log4j-user/201601.mbox/%3CD91F2A5E-92AD-4A94-BA89-CCB7B5F83974%40gmail.com%3E

      Thanks
      Veit

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ralph.goers@dslextreme.com Ralph Goers
                Reporter:
                vguna Veit Guna
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: