You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2015/03/26 22:48:53 UTC

[jira] [Commented] (LOG4J2-986) PatternLayout doesn't print "[%level]

    [ https://issues.apache.org/jira/browse/LOG4J2-986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14382752#comment-14382752 ] 

Gary Gregory commented on LOG4J2-986:
-------------------------------------

I cannot reproduce this.

> 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: Netbeans 8.0.2
>            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