When gathering Location Information in Log4jLogEvent
Log4j uses Thread.currentThread().getStackTrace()
Using (new Throwable()).getStackTrace(); would be more performant especially for larger stacks according to various benchmarks:
This can easily be verified with a simple JMH Benchmark test.
What would help in addition is to skip the Log4j Part when iterating over the StackTrace - use i=4 or whatever you may consider as being save enough instead of starting with i=0.
Basically something like: