You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (Jira)" <ji...@apache.org> on 2020/02/19 04:27:00 UTC

[jira] [Comment Edited] (LOG4J2-2785) Pattern Layout to abbreviate the name of all logger components except the 2 rightmost

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

Ralph Goers edited comment on LOG4J2-2785 at 2/19/20 4:26 AM:
--------------------------------------------------------------

Thank you for following up on my request at stackoverflow.com to open this. As it stands the abbreviator will also support a pattern like \{1.1.} which would print "o.a.commons.Foo". Unfortunately if the package name was "org.apache.logging.log4j.core.Foo" it would print "o.a.logging.log4j.core.Foo" so it doesn't really accomplish what you want.  I would suggest that modifying the Pattern Abbreviator to accept a pattern like \{1.2*} which would mean abbreviate everything except the last 2 "words" to a single character would be more useful.


was (Author: ralph.goers@dslextreme.com):
Thank you for following up on my request at stackoverflow.com to open this. As it stands the abbreviator will also support a pattern like \{1.1.} which would print "o.a.commons.Foo". Unfortunately if the package name was "org.apache.logging.log4j.core.Foo" it would print "o.a.logging.log4j.core.Foo" so it doesn't really accomplish what you want.  I would suggest that modifying the Pattern Abbreviator to accept a pattern like \{1.2} which would mean abbreviate everything except the last 2 "words" to a single character would be more useful.

> Pattern Layout to abbreviate the name of all logger components except the 2 rightmost
> -------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2785
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2785
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Layouts
>            Reporter: Rahul Khimasia
>            Assignee: Ralph Goers
>            Priority: Minor
>
> The following are my favorite patterns
> {quote}%c\{2} - which displays the corresponding number of rightmost logger name components. So a logger with a name like "org.apache.commons.Foo" is displayed as "commons.Foo".
> {quote}
> and
> {quote}%c\{1.} - which abbreviates the name based on the pattern. So a logger with a name like "org.apache.commons.Foo" is displayed as "o.a.c.Foo".
> {quote}
> Is there a way to combine the two. I want to abbreviate the name of all logger components except the 2 rightmost. Such that "org.apache.commons.Foo" is displayed as "o.a.commons.Foo".



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