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

Property substitution not working if <Properties> tag is not placed at the beginning of configuration

Details

    • Documentation
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.11.1
    • 2.11.2
    • Core
    • Any project with log4j using as configuration a file like the one attached as example.

      With this configuration, logs will be printed as ${defaultLayout} instead of the actual message.

    Description

      Tweaking my log configuration I found out that if the <Properties> is not placed at the beginning of the config just after the <Configuration> tag, the property substitution is not performed at all.

      Looking at the documentation I haven't seen anything related to the ordering of the elements in the config files. If there's a good reason that the properties should be placed first place in configuration, it'd be a good idea to note it somewhere in the documentation.

      Attachments

        1. log4j2.xml
          0.4 kB
          Javier Armendáriz

        Activity

          Commit 60b275d3d07b1a73a1bd639e49c64f670aec8895 in logging-log4j2's branch refs/heads/release-2.x from Ralph Goers
          [ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=60b275d ]

          LOG4J2-2500 - update documentation to say properties element must be first

          jira-bot ASF subversion and git services added a comment - Commit 60b275d3d07b1a73a1bd639e49c64f670aec8895 in logging-log4j2's branch refs/heads/release-2.x from Ralph Goers [ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=60b275d ] LOG4J2-2500 - update documentation to say properties element must be first
          rgoers Ralph Goers added a comment -

          Documentation has been added.

          rgoers Ralph Goers added a comment - Documentation has been added.

          Commit 82df7bfb190fcad48ffd8daeff0dd85761e310e9 in logging-log4j2's branch refs/heads/release-2.x from Ralph Goers
          [ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=82df7bf ]

          LOG4J2-2500 and LOG4J2-2543 - Add log4j-to-slf4j to bom pom.xml. Document that Properties element must be first

          jira-bot ASF subversion and git services added a comment - Commit 82df7bfb190fcad48ffd8daeff0dd85761e310e9 in logging-log4j2's branch refs/heads/release-2.x from Ralph Goers [ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=82df7bf ] LOG4J2-2500 and LOG4J2-2543 - Add log4j-to-slf4j to bom pom.xml. Document that Properties element must be first
          rgoers Ralph Goers added a comment -

          This is intentional. Looking at the documentation for property substitution this needs to be explicitly stated.

          rgoers Ralph Goers added a comment - This is intentional. Looking at the documentation for property substitution this needs to be explicitly stated.

          People

            Unassigned Unassigned
            jarmendariz Javier Armendáriz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: