How do I add fields to log4j2's JSON logs <p>Say I have a standard JSON log as in the example in the docs (below)</p> <pre><code>{ "logger":"com.foo.Bar", "timestamp":"1376681196470", "level":"INFO", "thread":"main", "message":"Message flushed with immediate flush=true" } </code></pre> <p>Now I want to add custom info to this log like so:</p> <pre><code>{ "logger":"com.foo.Bar", "timestamp":"1376681196470", "level":"INFO", "thread":"main", "message":"Message flushed with immediate flush=true", "extrainformation":"Some very important stuff I need to include", "extrainformation2":"Some other very important stuff I need to include" } </code></pre> <p>Is there a way to do this? The docs don't seem to mention anything about adding properties to the log object. Do I need to make a custom layout or programmatically add fields or what?</p> <p><a href="https://logging.apache.org/log4j/2.x/manual/layouts.html#JSONLayout" rel="nofollow">relevant log4j2 docs</a></p>