[ 
https://issues.apache.org/jira/browse/LOG4J2-1002?focusedWorklogId=420853&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-420853
 ]

ASF GitHub Bot logged work on LOG4J2-1002:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Apr/20 01:41
            Start Date: 12/Apr/20 01:41
    Worklog Time Spent: 10m 
      Work Description: rgoers commented on issue #214: LOG4J2-1002 - 
ThrowablePatternConverter should preserve EOF
URL: https://github.com/apache/logging-log4j2/pull/214#issuecomment-612548823
 
 
   I tried applying this and it caused unit test failures in log4j-taglib.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 420853)
    Remaining Estimate: 335h 50m  (was: 336h)
            Time Spent: 10m

> PatternLayout is missing a new line for Exceptions with the short option
> ------------------------------------------------------------------------
>
>                 Key: LOG4J2-1002
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1002
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Layouts, Pattern Converters
>    Affects Versions: 2.2
>         Environment: Windows, eclipse
>            Reporter: Robert Schaft
>            Priority: Major
>   Original Estimate: 336h
>          Time Spent: 10m
>  Remaining Estimate: 335h 50m
>
> I am struggeling to get the PatternLayout right when using %throwable, %ex or 
> similar.
> The first problem is, that if the exception is limited by the number of lines 
> (e.g. with the option {{short}} or providing a number), the converter 
> {{ExtendedThrowablePatternConverter}} doesn't attach a newline to the end of 
> the stack.
> On the other hand it does attach a newline at the end of the full stack.
> That is why
> {quote}
> {{<PatternLayout pattern="%msg%n%ex" />}}
> {quote}
> produces the expected result for message with and without throwables: there 
> are no empty lines in the log file and every log message starts in a new 
> line. 
> What about {{%ex\{short\}}}?
> {quote}
> {{<PatternLayout pattern="%msg%n%ex\{short\}" />}}
> {quote}
> This has the problem that messages with throwables do not end with a new 
> line. This produces all kinds of problems.
> Ok, let's add a newline
> {quote}
> {{<PatternLayout alwaysWriteExceptions="false" pattern="%msg%n%ex\{short\}%n" 
> />}}
> {quote}
> This has the problem that messages _without_ throwables are followed by an 
> empty line. This is not acceptable on the console.
> So we need something more complicated:
> {quote}
> {{<PatternLayout alwaysWriteExceptions="false" 
> pattern="%msg%replace\{%n%ex\{short\}%n\}\{\[\r\n]+$\}\{\}%n" />}}
> {quote}
> Yeah! It works (at least on Windows, Unix, Linux, Mac) and if the 
> undocumented throwable {{separator}} option is not used. But it's ugly and 
> requires the alwaysWriteExceptions because the throwable pattern detection 
> does not work any more.
> Short Term solution: Always add a newline to the exception.
> Long Term Solution:
> Add a conversion pattern {{%onThrowable\{pattern1\}\[\{pattern2\}]}} where 
> pattern1 is appended when there is a throwable attached to the log message 
> and the optional pattern2 is appended when there is no throwable appended.
> The {{alwaysWriteExceptions="false"}} parameter could be replaced by 
> {{pattern="%onThrowable\{\}"}} 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to