I am using GELF-logstash appender together with log4j2
as logging appender, to send logs from my application through logstash to ElasticSearch/Kibana.
In each log message I want to configure a static field, namely the region my application is deployed to, which is gathered from an environment variable differing by the region the application is running in.
I found out that Static Literals are supported by the XML configuration like this: <Field name="fieldName1" literal="your literal value" />
https://logging.paluch.biz/examples/log4j-2.x.html
But I would like to stay with my log4j2.properties
file based configuration if possible, but could not find a documentation to add a static literal there.
Yes, this is possible. You can use the pre-defined field
facility
, or define as many custom static fields as you wish in yourlog4j2.properties
file: