我的应用程序使用log4j2套接字附加程序和JsonLayout将日志事件发送到logstash。在kibana中,我想以json格式(而不是stacktrace)显示所有其他属性。
log4j2.xml configuration
<Socket host="localhost" name="mySocketAppender" port="9955">
<JsonLayout compact="true" eventEol="true" includeStacktrace="true" properties="true
</Socket>
logstash.config
input {
tcp {
port => 9955
codec => json
}
}
filter {
date {
match => [ "timeMillis", "UNIX_MS" ]
}
}
output {
elasticsearch { hosts => ["localhost:9200"]}
}
我希望输出为
Caused by: java.lang.NullPointerException
at java.net.URLEncoder.encode(URLEncoder.java:204) ~[?:1.8.0_151]
at com.mytestClass.service.test.generateURL(test.java:1922) ~[abc-xyz.jar:?]
at com.mytestClass.service.test.publishURLToUsers(test.java:1847) ~[abc-xyz.jar:?]
at com.mytestClass.service.test..publishURL(test.java:1809) ~[abc-xyz.jar:?]
但是Kibana将stacktrace的输出显示为:
thrown.cause.extendedStackTrace {
"exact": false,
"location": "?",
"class": "java.net.URLEncoder",
"file": "URLEncoder.java",
"version": "1.8.0_151",
"method": "encode",
"line": 204
},
{
"exact": false,
"location": "abc-xyz.jar",
"class": "com.mytestClass.service.test",
"file": "test.java",
"version": "?",
"method": "generateURL",
"line": 1922
},
{
"exact": false,
"location": "abc-xyz.jar",
"class": "com.mytestClass.service.test",
"file": "test.java",
"version": "?",
"method": "publishURLToUsers",
"line": 1847
},
{
"exact": false,
"location": "abc-xyz.jar",
"class": "com.mytestClass.service.test",
"file": "test.java",
"version": "?",
"method": "publishURL",
"line": 1809
}
我应该在logstash配置中进行哪些更改,以使log事件中的所有其他属性都以json格式显示,但不显示异常stacktrace。