If you use JSONLayout of log4j2, the output date and time will be output in epoch seconds.
log.json
{
"instant": {
"epochSecond": 1563403242,
"nanoOfSecond": 895000000
}
}
Since it is difficult to read the epoch seconds directly like a human being, I would like to output the date normally.
So do this.
log4j2.xml
<JsonLayout>
<!--Abbreviation-->
<KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd'T'HH:mm:ss,SSSXXX}"/>
</JsonLayout>
result
log.json
{
"timestamp": "2019-07-18T07:40:42,895+09:00"
}