logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johno Crawford (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-1572) Empty NDC stack logs null
Date Fri, 09 Sep 2016 08:06:20 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-1572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Johno Crawford updated LOG4J2-1572:
-----------------------------------
    Description: 
Expected behavior

When the NDC stack is empty nothing should be logged (regression in log4j 2.x, the functionality
behaves this way in log4j 1.2).

ex. 2016-09-09 09:54:44,212 INFO  [main] Main (Main.java:6) - huuhaa

Actual behavior

When the NDC stack is empty null is logged.

ex. 2016-09-09 09:54:44,212 INFO  [main] Main (Main.java:6) - huuhaa null

{code:java}
import org.apache.logging.log4j.LogManager;

public class Main {

    public static void main(String[] args) {
        LogManager.getLogger(Main.class).info("huuhaa");
    }
}
{code}

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
  <Appenders>
    <Console name="STDOUT" target="SYSTEM_OUT">
      <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m %x%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Root level="INFO">
      <AppenderRef ref="STDOUT"/>
    </Root>
  </Loggers>
</Configuration>
{code}

  was:
Expected behavior

When the NDC stack is empty nothing should be logged (regression in log4j 2.x, the functionality
behaves this way in log4j 1.2).

ex. 2016-09-09 09:54:44,212 INFO  [main] Main (Main.java:6) - huuhaa

Actual behavior

When the NDC stack is empty null is logged.

ex. 2016-09-09 09:54:44,212 INFO  [main] Main (Main.java:6) - huuhaa null

```java
import org.apache.logging.log4j.LogManager;

public class Main {

    public static void main(String[] args) {
        LogManager.getLogger(Main.class).info("huuhaa");
    }
}
```

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
  <Appenders>
    <Console name="STDOUT" target="SYSTEM_OUT">
      <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m %x%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Root level="INFO">
      <AppenderRef ref="STDOUT"/>
    </Root>
  </Loggers>
</Configuration>
```


> Empty NDC stack logs null
> -------------------------
>
>                 Key: LOG4J2-1572
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1572
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.6.2
>            Reporter: Johno Crawford
>            Priority: Trivial
>
> Expected behavior
> When the NDC stack is empty nothing should be logged (regression in log4j 2.x, the functionality
behaves this way in log4j 1.2).
> ex. 2016-09-09 09:54:44,212 INFO  [main] Main (Main.java:6) - huuhaa
> Actual behavior
> When the NDC stack is empty null is logged.
> ex. 2016-09-09 09:54:44,212 INFO  [main] Main (Main.java:6) - huuhaa null
> {code:java}
> import org.apache.logging.log4j.LogManager;
> public class Main {
>     public static void main(String[] args) {
>         LogManager.getLogger(Main.class).info("huuhaa");
>     }
> }
> {code}
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration>
>   <Appenders>
>     <Console name="STDOUT" target="SYSTEM_OUT">
>       <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m %x%n"/>
>     </Console>
>   </Appenders>
>   <Loggers>
>     <Root level="INFO">
>       <AppenderRef ref="STDOUT"/>
>     </Root>
>   </Loggers>
> </Configuration>
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message