0
我找打印出日誌中的自定義方式。如何打印自定義字段爲從Java應用程序日誌文件與log4j2 JSON技術的幫助?
例如,
目前,我們有以下的JSON形式的日誌結構,
{
"timeMillis" : 1488791217953,
"thread" : "restartedMain",
"level" : "DEBUG",
"loggerName" : "org.springframework.jdbc.datasource.DriverManagerDataSource",
"message" : "hello world",
"endOfBatch" : false,
"loggerFqcn" : "org.apache.commons.logging.impl.SLF4JLocationAwareLog",
"threadId" : 17,
"threadPriority" : 5
}
現在我發現,有幾個字段仍然失蹤這是很重要我有一個日誌,
預期JSON是同樣:
{
"timeMillis" : 1488791217953,
"thread" : "restartedMain",
"level" : "DEBUG",
..................
"file" : "p1.pck.HelloWorld.java",
"line" : "190",
"application-id" : "101",
"logged in user id " : "199",
"etc" : "etc"
..................
"threadPriority" : 5
}
注:日誌配置文件log4j2.yml
有以下配置
JsonLayout:
propertiesAsList: true