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

Log4j-config.xsd only allows one AppenderRef element for each Logger element

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.2
    • Fix Version/s: 2.9.0
    • Component/s: Configurators
    • Labels:
      None
    • Environment:

      Alle environments

      Description

      The xsd schema definition for the log4j configuration allow only one AppenderRef per Logger. The definition of the Logger element is as follows

      <xs:complexType name="LoggerType">
          <xs:sequence>
              <xs:choice minOccurs="0" maxOccurs="1">
                  <xs:element name="Filters" type="FiltersType"/>
                  <xs:element name="Filter" type="FilterType"/>
              </xs:choice>
              <xs:element name="AppenderRef" type="AppenderRefType"/>
          </xs:sequence>
          <xs:attribute name="name" type="xs:string" use="required"/>
          <xs:attribute name="level" type="xs:string" use="optional"/>
          <xs:attribute name="additivity" type="xs:string" use="optional"/>
      </xs:complexType>
      

      Comparing this to the Definition of the root Logger we see a sequence of multiple Appender
      Ref elements to be allowed.

      <xs:complexType name="RootType">
          <xs:sequence>
                  <xs:element name="AppenderRef" type="AppenderRefType" minOccurs="1" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="level" type="xs:string"/>
      </xs:complexType>
      

      With this configuration it is not possible to define a specific Logger, that shows infos and errors to the console and writes only the errors in a log file, since there can only be one appender defined for that logger.

      Please modify the xsd file to allow mutliple AppenderRef elements per Logger.

        Issue Links

          Activity

          Hide
          garydgregory Gary Gregory added a comment -
          Show
          garydgregory Gary Gregory added a comment - Right! Fixing with https://issues.apache.org/jira/browse/LOG4J2-2073
          Hide
          plucas Patrick Lucas added a comment -

          Shouldn't this have minOccurs="0" since omitting the AppenderRef is allowed? (in which case it delegates to the root logger, I think)

          Show
          plucas Patrick Lucas added a comment - Shouldn't this have minOccurs="0" since omitting the AppenderRef is allowed? (in which case it delegates to the root logger, I think)
          Hide
          scotty24 Christoph Lembeck added a comment -

          Fix is verified. Thanks a lot!

          Show
          scotty24 Christoph Lembeck added a comment - Fix is verified. Thanks a lot!
          Hide
          garydgregory Gary Gregory added a comment -

          In git master. Please verify and close.

          Show
          garydgregory Gary Gregory added a comment - In git master. Please verify and close.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit aabb33971bdde1f74679384f992fc2035013906c in logging-log4j2's branch refs/heads/master from Gary Gregory
          [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=aabb339 ]

          LOG4J2-1982 Log4j-config.xsd only allows one AppenderRef element for
          each Logger element.

          Show
          jira-bot ASF subversion and git services added a comment - Commit aabb33971bdde1f74679384f992fc2035013906c in logging-log4j2's branch refs/heads/master from Gary Gregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=aabb339 ] LOG4J2-1982 Log4j-config.xsd only allows one AppenderRef element for each Logger element.

            People

            • Assignee:
              Unassigned
              Reporter:
              scotty24 Christoph Lembeck
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development