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.

        Activity

        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.
        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
        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!

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development