【发布时间】:2018-07-17 19:19:49
【问题描述】:
正如每个人都可以在他们的GitHub page 中看到的那样,property 标记有一个内部 type 标记,它应该告诉 Elasticsearch 是否应该写入该属性的值作为字符串,数字...在生成的 JSON 中(至少我是这么理解的):
type(可选,默认字符串):结果字段的类型 JSON 消息。可能的值有:String、int、float 和 boolean。
但我不能让它工作。
这是我的 logback.xml 文件的 sn-p:
<appender name="ELASTIC" class="com.internetitem.logback.elasticsearch.ElasticsearchAppender">
...
<property>
<name>elapsed time (ms)</name>
<value>%X{elapsedTime}</value>
<type>int</type>
</property>
...
</appender>
我正在使用 JoranConfigurator 配置 logback:
String logConfigurationPath = "logback.xml";
if (logConfigurationPath != null) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator config = new JoranConfigurator();
config.setContext(context);
context.reset();
config.doConfigure(logConfigurationPath);
} catch (JoranException je) {
}
StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}
Logback 配置正常,但是当它尝试处理该 type 标记时出现错误:
testingdocker | 09:46:13,134 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@68:23 - no applicable action for [type], current ElementPath is [[configuration][appender][properties][property][type]]
Elastic 在生成的 JSON 中将该标签设置为字符串,我可以在 Kibana 中进行检查。
如何正确使用该标签,以便从 Logback 获取 Kibana 中的数字类型?
【问题讨论】:
标签: java elasticsearch kibana logback