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

Raman Gupta commented on LOG4J2-2196:
-------------------------------------

Hi [~garydgregory],  here is the configuration file: 
https://gist.github.com/rocketraman/05eab786d5a172ff80b9a909d5587d3a

 

Here is the program:

{{import org.apache.logging.log4j.LogManager;}}
{{import org.apache.logging.log4j.Logger;}}
{{public class TestLogging {}}
{{  private static final Logger logger = LogManager.getLogger("HelloWorld");}}
{{  public static void main(String[] args) {}}
{{    logger.error("This is a test.", new Exception("Test exception!"));}}
{{  }}}
{{}}}

 

And here is the output:



{{2018-01-18 18:51:32,469 | This is a test. | EXCEPTION: java.lang.Exception: 
Test exception!}}
{{ at TestLogging.main(TestLogging.java:8)}}
{{}}{{java.lang.Exception: Test exception!}}
{{ at TestLogging.main(TestLogging.java:8) [classes/:?]}}

> Pattern layout %notEmpty does not work for exceptions
> -----------------------------------------------------
>
>                 Key: LOG4J2-2196
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2196
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Pattern Converters
>    Affects Versions: 2.10.0
>            Reporter: Raman Gupta
>            Priority: Major
>
> Using a pattern layout that contains something like:
> {{%notEmpty\{EXCEPTION: %throwable}}}
> kind of works. However, when the Exception is not empty, it prints the 
> Exception to the appender twice: once in the proper position within the 
> pattern, and then again completely separately, with a newline before the 
> second output.
> Note that the second output completely ignores any formatting specifications, 
> such as separator or level-based ansi coloring – it seems as if the output of 
> Exception.toString() had been sent to the appender directly).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to