Actually, I receive a message through RabbitMQ which is large.
While consuming this message, we log it.

logger.info("payload: {}", payload);

I see the following exception in logs at the logger statement line.

Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)
at java.lang.StringBuffer.append(StringBuffer.java:272)
at org.apache.log4j.helpers.PatternParser$LiteralPatternConverter.format(PatternParser.java:419)
at org.apache.log4j.PatternLayout.format(PatternLayout.java:506)
at org.graylog2.GelfMessageFactory.makeMessage(GelfMessageFactory.java:37)
at org.graylog2.log.GelfAppender.append(GelfAppender.java:220)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.slf4j.impl.Log4jLoggerAdapter.info(Log4jLoggerAdapter.java:324)

After getting rid of the logger statement, the message was processed successfully.

Q: So, can I be sure that the logger was causing the OutOfMemory error? Or it is something else that is causing the OutOfMemory Error?

A:
Based on the stack trace, yes.

From the trace you can evidently see that your log4j module (which is the logger object) was trying to perform a copyOf() operation but before the copy was done the program died with OutOfMemoryException.

As to how you would generally read the stack trace, this stackoverflow post can be a great help.

Generally the exact reason for the Exception is at the first line of
your Stack Trace, and for more information about the cause of that
exception, you need to gradually move down, and the root cause can
often be found somewhere near the bottom of the stack trace.

I generally read the first line of the stack trace to determine what is happening, for your cause would be the OOM error, then I move to the last line and read from bottom up to see which object or area of code that could have caused the fault.