Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.11.0
-
None
-
None
-
Testing was on Windows 7 with JDK 8. Production will be on Linux with JDK 8.
Description
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:
%c{2.} %c{2.1} %c{1.2}
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?
Attachments
Issue Links
- is duplicated by
-
LOG4J2-2785 Pattern Layout to abbreviate the name of all logger components except the 2 rightmost
- Closed