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.

        Attachments

          Activity

            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: