Log JSON object with log4j JsonLayout Log JSON object with log4j JsonLayout json json

Log JSON object with log4j JsonLayout


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>