Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4j2 KeyValuePair for .properties file

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

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

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

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'}`

?

like image 359
mr nooby noob Avatar asked Sep 22 '16 21:09

mr nooby noob


1 Answers

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
like image 77
Robert Metzger Avatar answered Sep 30 '22 20:09

Robert Metzger