logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Grégoire (JIRA) <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-986) PatternLayout doesn't print "[%level]
Date Thu, 26 Mar 2015 12:09:53 GMT

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

Olivier Grégoire updated LOG4J2-986:
------------------------------------
    Description: 
This configuration

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="[%level] %message%exception{short}%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>
{code}

And this unit test:

{code:title=Log4j2Test.java|borderStyle=solid}
import org.apache.logging.log4j.LogManager;
import org.junit.Test;
public class Log4j2Test {
  @Test public void testLogging() {
    LogManager.getLogger().info("expecting [INFO]", new RuntimeException());
  }
}
{code}

Result in the following:

{noformat}
expecting [INFO] java.lang.RuntimeException
    at Log4j2Test.testLogging(Log4j2Test.java:19)
{noformat}

I would expect:


{noformat}
[INFO] expecting [INFO] java.lang.RuntimeException
    at Log4j2Test.testLogging(Log4j2Test.java:19)
{noformat}

I found this issue in 2.1 and I reproduced it in 2.2.

Note: similar patterns like the following work as expected.

{noformat}
[%-5level] %message%exception{short}%n
%level %message%exception{short}%n
{noformat}

  was:
This configuration

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="[%level] %message%exception{short}%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>
{code}

And this unit test:

{code:title=Log4j2Test.java|borderStyle=solid}
import org.apache.logging.log4j.LogManager;
import org.junit.Test;
public class Log4j2Test {
  @Test public void testLogging() {
    LogManager.getLogger().info("expecting [INFO]", new RuntimeException());
  }
}
{code}

Result in the following:

{noformat}
expecting [INFO] java.lang.RuntimeException
    at Log4j2Test.testLogging(Log4j2Test.java:19)
{noformat}

I would expect:


{noformat}
[INFO] expecting [INFO] java.lang.RuntimeException
    at Log4j2Test.testLogging(Log4j2Test.java:19)
{noformat}

I found this issue in 2.1 and I reproduced it in 2.2.

Note: similar patterns like the following work as expected.

{noformat}
[%-5level] %message%exception{short}%n
{noformat}


> PatternLayout doesn't print "[%level]
> -------------------------------------
>
>                 Key: LOG4J2-986
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-986
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.2
>         Environment: Java 1.8 on Windows
>            Reporter: Olivier Grégoire
>
> This configuration
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration>
>     <Appenders>
>         <Console name="Console" target="SYSTEM_OUT">
>             <PatternLayout pattern="[%level] %message%exception{short}%n"/>
>         </Console>
>     </Appenders>
>     <Loggers>
>         <Root level="trace">
>             <AppenderRef ref="Console"/>
>         </Root>
>     </Loggers>
> </Configuration>
> {code}
> And this unit test:
> {code:title=Log4j2Test.java|borderStyle=solid}
> import org.apache.logging.log4j.LogManager;
> import org.junit.Test;
> public class Log4j2Test {
>   @Test public void testLogging() {
>     LogManager.getLogger().info("expecting [INFO]", new RuntimeException());
>   }
> }
> {code}
> Result in the following:
> {noformat}
> expecting [INFO] java.lang.RuntimeException
>     at Log4j2Test.testLogging(Log4j2Test.java:19)
> {noformat}
> I would expect:
> {noformat}
> [INFO] expecting [INFO] java.lang.RuntimeException
>     at Log4j2Test.testLogging(Log4j2Test.java:19)
> {noformat}
> I found this issue in 2.1 and I reproduced it in 2.2.
> Note: similar patterns like the following work as expected.
> {noformat}
> [%-5level] %message%exception{short}%n
> %level %message%exception{short}%n
> {noformat}



--
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