# LogstashSocketAppender include environment variable in output

**URL:** <https://discuss.elastic.co/t/logstashsocketappender-include-environment-variable-in-output/118940>\
**Category:** Logstash\
**Created:** [February 7, 2018, 10:56pm UTC](https://discuss.elastic.co/t/logstashsocketappender-include-environment-variable-in-output/118940 "2018-02-07T22:56:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtanner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dtanner/32/27494_2.png) [@dtanner](https://discuss.elastic.co/u/dtanner)\
**Post date:** [February 7, 2018, 10:56pm UTC](https://discuss.elastic.co/t/logstashsocketappender-include-environment-variable-in-output/118940/1 "2018-02-07T22:56:15Z")

</div>

Can you include the value of an environment variable in the json output when using the LogstashSocketAppender?

e.g. How would I include the value of an environment variable named FOO with every log message? Would it look something like this?

```
<appender name="SOCKET" class="net.logstash.logback.appender.LogstashSocketAppender">
  <host>127.0.0.1</host>
  <port>1511</port>
  <provider class="net.logstash.logback.composite.loggingevent.LoggingEventPatternJsonProvider">
    <pattern>
      {
      "foo": "???"
      }
    </pattern>
  </provider>
</appender>

```

p.s. Also posted the question at stackoverflow: [https://stackoverflow.com/questions/48672503/logback-logstashsocketappender-include-environment-variable-in-output](https://stackoverflow.com/questions/48672503/logback-logstashsocketappender-include-environment-variable-in-output)

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 7, 2018, 10:56pm UTC](https://discuss.elastic.co/t/logstashsocketappender-include-environment-variable-in-output/118940/2 "2018-03-07T22:56:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
