本文介绍了.properties文件的log4j2 KeyValuePair的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在属性文件的log4j2中创建键值对?

How do I create a keyvaluepair in log4j2 in a propterties file?

我知道在log4j版本1中它是这样完成的:

I know in log4j version 1 it's done like:

log4j.appender.x.additionalFields={'key': 'value'}

和log4j2中的XML方式是:

and the XML way for it in log4j2 is:

  <KeyValuePair key="key" value="value"/>

对于这样的属性文件来说是一种方法:

so is way to do it for a properties file like this:

`appender.x.keyValuePair ={'key': 'value'}`

?

推荐答案

这是如何为Graylog2(GELF)附加程序定义键值对的有效示例:

This is a working example of how to define a key value pair for example for the Graylog2 (GELF) appender:

appender.graylog.type=GELF
appender.graylog.name=GRAYLOG
appender.graylog.server=yourhostname
appender.graylog.includeStackTrace=true
appender.graylog.additional1.type=KeyValuePair
appender.graylog.additional1.key=yarncontainer
appender.graylog.additional1.value=containerXYZ
appender.graylog.additional2.type=KeyValuePair
appender.graylog.additional2.key=anotherKey
appender.graylog.additional2.value=anotherValue

这篇关于.properties文件的log4j2 KeyValuePair的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:44