Description
Background: during investigation of LOG4J2-245, several people raised performance concerns regarding ThrowableProxy. This issue is to separate that concern so that LOG4J2-245 can focus on resolving the EmptyStackException.
ThrowableProxy does quite a bit of expensive-looking work to find the JAR file or directory where the class that threw the exception is located. This work is done for every event that contains an exception.
However, this information is only used when the configuration contains either a RootThrowablePattern
or an ExtendedThrowablePattern
{"xEx", "xThrowable", "xException" }or when the LogEvent is serialized.
I propose to change the Log4jLogEvent implementation: instead of unconditionally creating a ThrowableProxy object every time a log event contains an exception, only wrap this exception in a ThrowableProxy when either:
- the getThrownProxy() method is called
- the log event is serialized
For reference, similar work has already been done on o.a.l.l.core.async.RingBufferLogEvent.
Attachments
Issue Links
- is related to
-
LOG4J2-245 EmptyStackException when logging exceptions with Log4J2 in Java 8
- Resolved
-
LOG4J2-654 Use JMH for Log4j2 performance tests
- Closed