Is it possible to configure log4j2 in such a way that the stacktraces don't show the source and maybe not the line numbers?
In case you are wondering why I would want that, I need this for unit tests, that need to test if exceptions get logged correctly. So if for example the JRE version is not the same as the one I copied the original stacktrace, from the tests fail. So if the source wasn't included in the stacktrace it would be a lot more version independend.
Example:
Currently a line from the stacktrace looks like this:
at java.lang.Object.wait(Object.java:502) ~[?:1.8.0_144]
I would like it to look like this (but only for log4j2):
at java.lang.Object.wait(Object.java:502)
Maybe even like this:
at java.lang.Object.wait(Object.java)
Or even shorter:
at java.lang.Object.wait
(Any of the shortened versions would be acceptable. As currently only the source (~[?:1.8.0_144]
vs ~[?:1.8.0_151]
for example) differs.)
Update:
I just found this in the offical documentation: https://logging.apache.org/log4j/2.x/manual/layouts.html#Patterns I think using %ex{full}
should be what I want. Will test it.
There are also several other available formats.