You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2017/08/16 05:11:00 UTC

[jira] [Created] (LOG4J2-2018) LoggerNameLevelRewritePolicy documentation is wrong, example is broken

Remko Popma created LOG4J2-2018:
-----------------------------------

             Summary: LoggerNameLevelRewritePolicy documentation is wrong, example is broken
                 Key: LOG4J2-2018
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2018
             Project: Log4j 2
          Issue Type: Bug
          Components: Appenders, Documentation
    Affects Versions: 2.8.2
            Reporter: Remko Popma
            Assignee: Remko Popma
             Fix For: 2.9


The documentation on the [LoggerNameLevelRewritePolicy|http://logging.apache.org/log4j/2.x/manual/appenders.html#RewriteAppender] is wrong:

Following the example in the documentation gives an error.

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

The {{loggerName}} does not exist, resulting in this error:

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

The implementation looks like this, it appears that the configuration should use {{logger}} instead:
{code}
@PluginFactory
public static LoggerNameLevelRewritePolicy createPolicy(
    // @formatter:off
    @PluginAttribute("logger") final String loggerNamePrefix,
    @PluginElement("KeyValuePair") final KeyValuePair[] levelPairs) {
...
{code}

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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)