Log4j 2
  1. Log4j 2
  2. LOG4J2-482

The attribute of Route to refer to an appender is "ref" not "AppenderRef"

    Details

    • Type: Documentation Documentation
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta9
    • Fix Version/s: 2.0-rc1
    • Component/s: Appenders
    • Labels:

      Description

      First of all, thanks for so much enhancements on log4j2. : )
      Just a small problem of the manual. The example of Routes(http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender) uses attribute "AppenderRef" to reference an appender, which is not correct. I've searched the source code, find the attribute should be "ref".

        Activity

        Hide
        Remko Popma added a comment -

        Thanks for pointing this out.
        I've changed the documentation to use the "ref" attribute.
        (Interestingly, there are five JUnit tests with separate configuration files that all correctly use "ref". It seems like the docs have had this mistake from the beginning.)

        Fixed in revision 1555091.
        Please verify and close.

        Note to the team:
        Perhaps this attribute should be AppenderRef instead of ref.
        The code changes to do this seem fairly straightforward, but this may break existing configurations. At this point the documentation is simply wrong so I'm just fixing the documentation.

        Show
        Remko Popma added a comment - Thanks for pointing this out. I've changed the documentation to use the "ref" attribute. (Interestingly, there are five JUnit tests with separate configuration files that all correctly use "ref". It seems like the docs have had this mistake from the beginning.) Fixed in revision 1555091. Please verify and close. Note to the team: Perhaps this attribute should be AppenderRef instead of ref . The code changes to do this seem fairly straightforward, but this may break existing configurations. At this point the documentation is simply wrong so I'm just fixing the documentation.
        Hide
        Gary Gregory added a comment -

        I would vote for whatever is consistent with the rest of the configuration schema.

        Show
        Gary Gregory added a comment - I would vote for whatever is consistent with the rest of the configuration schema.
        Hide
        Remko Popma added a comment -

        (Reopening issue)
        Now that we are talking about coming out of beta on the mailing list, perhaps now is the best time to change this attribute from "ref" to "AppenderRef".

        I'll change the docs back to "AppenderRef".
        I'll change the implementation to accept either "AppenderRef" or (for backwards compatibility) "ref". If both are specified, AppenderRef wins.

        Show
        Remko Popma added a comment - (Reopening issue) Now that we are talking about coming out of beta on the mailing list, perhaps now is the best time to change this attribute from "ref" to "AppenderRef". I'll change the docs back to "AppenderRef". I'll change the implementation to accept either "AppenderRef" or (for backwards compatibility) "ref". If both are specified, AppenderRef wins.
        Hide
        Remko Popma added a comment - - edited

        Hmm... Perhaps I was too enthusiastic there...

        After taking another good look, using ref (and not AppenderRef) may be the most consistent.
        For reference, Root and Logger config elements look like this:

            <Root level="info">
              <AppenderRef ref="RollingFile"/>
            </Root>
        

        Compare to the Route config element:

            <Routing name="Routing">
              <Routes pattern="$${sd:type}">
                ...
                <Route ref="AuditLogger" key="Audit"/>
              </Routes>
            </Routing>
        

        So it looks like just fixing the documentation was the correct thing to do and there is no need for further code changes.
        I will mark this issue as 'fixed' again. Sorry for the confusion.

        Show
        Remko Popma added a comment - - edited Hmm... Perhaps I was too enthusiastic there... After taking another good look, using ref (and not AppenderRef ) may be the most consistent . For reference, Root and Logger config elements look like this: <Root level= "info" > <AppenderRef ref= "RollingFile" /> </Root> Compare to the Route config element: <Routing name= "Routing" > <Routes pattern= "$${sd:type}" > ... <Route ref= "AuditLogger" key= "Audit" /> </Routes> </Routing> So it looks like just fixing the documentation was the correct thing to do and there is no need for further code changes. I will mark this issue as 'fixed' again. Sorry for the confusion.
        Hide
        Hongdi Ren added a comment - - edited

        Hi Remko,
        Thanks for the quick update and your enthusiastic. We need such kind of review and thinking to understand the case better.
        This issue could be closed after the manual on website updated.
        And as a junior developer, thanks again for the high quality code to learn from. : )

        Show
        Hongdi Ren added a comment - - edited Hi Remko, Thanks for the quick update and your enthusiastic. We need such kind of review and thinking to understand the case better. This issue could be closed after the manual on website updated. And as a junior developer, thanks again for the high quality code to learn from. : )
        Hide
        Remko Popma added a comment -

        Hongdi, thank you for bringing it to our attention.

        Show
        Remko Popma added a comment - Hongdi, thank you for bringing it to our attention.

          People

          • Assignee:
            Remko Popma
            Reporter:
            Hongdi Ren
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 5m
              5m
              Remaining:
              Remaining Estimate - 5m
              5m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development