Java app runs in a k8s container and writes log messages to a stdout with the next appender:
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<JsonLayout compact="true" eventEol="true" />
</Console>
</Appenders>
to get collected by fluentd and transferred to ELK.
I'm not a Java developer, but I wonder if I can somehow get rid of the Java stack trace Exception in thread "main" ... in stdout after the normal log4j2 log record, containing the same message in JSON.
Try below configuration -
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<JsonLayout compact="true" eventEol="true" includeStacktrace="false" />
</Console>
</Appenders>
With includeStacktrace=false only the class name and message of the Throwable will be logged. Full stacktrace of the exception will not be logged. Check more details here