There is an objectMessageAsJsonObject that should do this for you.In your log4j2.xml:
<RollingFile name="json-log" fileName="build/log" filePattern="/var/log/.%d{yyyy-MM-dd}.log"> <JSONLayout objectMessageAsJsonObject="true"/> </RollingFile>