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

LoggerNameLevelRewritePolicy documentation is wrong, example is broken

    Details

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

      Description

      The documentation on the LoggerNameLevelRewritePolicy is wrong:

      Following the example in the documentation gives an error.

            <LoggerNameLevelRewritePolicy loggerName="com.foo.bar">
              <KeyValuePair key="INFO" value="DEBUG"/>
              <KeyValuePair key="WARN" value="INFO"/>
            </LoggerNameLevelRewritePolicy>
      

      The loggerName does not exist, resulting in this error:

      2017-08-16 13:46:13,712 main ERROR LoggerNameLevelRewritePolicy contains an invalid element or attribute "loggerName"

      The implementation looks like this, it appears that the configuration should use logger instead:

      @PluginFactory
      public static LoggerNameLevelRewritePolicy createPolicy(
          // @formatter:off
          @PluginAttribute("logger") final String loggerNamePrefix,
          @PluginElement("KeyValuePair") final KeyValuePair[] levelPairs) {
      ...
      

      I think loggerName is a more descriptive name for the attribute, but users may already be using logger after checking the implementation.

      Can we give this attribute an alias so that both loggerName and logger work? That way we can keep the current (descriptive) documentation and avoid breaking users existing configuration.

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 8777af527862596b0adeaf148896d1085e69d191 in logging-log4j2's branch refs/heads/master from rpopma
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=8777af5 ]

        LOG4J2-2018 Fix incorrect documentation for LoggerNameLevelRewritePolicy

        Show
        jira-bot ASF subversion and git services added a comment - Commit 8777af527862596b0adeaf148896d1085e69d191 in logging-log4j2's branch refs/heads/master from rpopma [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=8777af5 ] LOG4J2-2018 Fix incorrect documentation for LoggerNameLevelRewritePolicy
        Hide
        remkop@yahoo.com Remko Popma added a comment -

        Fixed the docs rather than the implementation.

        Show
        remkop@yahoo.com Remko Popma added a comment - Fixed the docs rather than the implementation.

          People

          • Assignee:
            remkop@yahoo.com Remko Popma
            Reporter:
            remkop@yahoo.com Remko Popma
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development