说我有一个标准的JSON日志,如docs中的示例所示(如下)
{ "logger":"com.foo.Bar", "timestamp":"1376681196470", "level":"INFO", "thread":"main", "message":"Message flushed with immediate flush=true" }
现在,我想向此日志添加自定义信息,如下所示:
{ "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" }
有没有办法做到这一点?文档似乎没有提及有关向日志对象添加属性的任何内容。我是否需要进行自定义布局或以编程方式添加字段或其他内容?
相关的log4j2文档