Shawn Heisey created LOG4J2-2401:
------------------------------------
Summary: Extend %c conversion pattern - separately control the
number of characters in each class component and the number of elements that
are fully specified
Key: LOG4J2-2401
URL: https://issues.apache.org/jira/browse/LOG4J2-2401
Project: Log4j 2
Issue Type: Improvement
Components: Pattern Converters
Affects Versions: 2.11.0
Environment: Testing was on Windows 7 with JDK 8. Production will be
on Linux with JDK 8.
Reporter: Shawn Heisey
I want to be able to achieve something with the %c conversion pattern that
isn't possible at the moment.
Given a logger name of "org.apache.solr.core.SolrCore.Request", I want the log
to contain "o.a.s.c.SolrCore.Request" -- single character abbreviations for all
components except the last two.
Solr's log4j configuration currently includes a conversion pattern of
%\c{1.\}.This changes the logger name I mentioned above to "o.a.s.c.S.Request".
With only one class name component fully specified, it's difficult to find the
logger -- particularly in this case, because the logger name is special and
doesn't refer to an actual class.
(if you see backslashes in the pattern string, ignore them -- they're necessary
so Jira doesn't interpret the curly braces a special characters)
I tried to get log4j to do what I was after, with the following conversion
patterns:
{noformat}
%c{2.}
%c{2.1}
%c{1.2}
{noformat}
All three of these patterns produced "or.ap.so.co.So.Request" in the log. I
would have expected the pattern with 1.2 to be the correct one. Is it possible
to modify the code so that the number of characters in the abbreviated
components can be specified separately from the number of trailing components
that are NOT abbreviated?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)