I'm trying to trim logger names in Log4j2 Core's PatternLayout.
Examples logger name:
com.test1.test2.test3.test4.test5.ClassName
Expected output:
c.t.t.t.t.test5.ClassName
In the docs I can only trim from the end not from beginning.
Any suggestions would be helpful.
There is no pattern that allows you to abbreviate all components except the last two. This has been reported in LOG4J2-2785 and there is work in progress on this issue.
Edit: Since version 2.19.1
you can use the following pattern to abbreviate all components, except the last two:
1.2*
See also this question.