# Logstash log4j configuration pipeline.id

**URL:** <https://discuss.elastic.co/t/logstash-log4j-configuration-pipeline-id/169455>\
**Category:** Logstash\
**Created:** [February 21, 2019, 3:51pm UTC](https://discuss.elastic.co/t/logstash-log4j-configuration-pipeline-id/169455 "2019-02-21T15:51:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![janmg](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@janmg](https://discuss.elastic.co/u/janmg)\
**Post date:** [February 21, 2019, 3:51pm UTC](https://discuss.elastic.co/t/logstash-log4j-configuration-pipeline-id/169455/1 "2019-02-21T15:51:41Z")

</div>

I created an logstash input plugin in jruby and when I do an @logger.info("log entry"), I'd like it to have a pipeline.id in the logstash-plain.log as generated by log4j2. Since I have several pipelines it's nice to use the pipeline.id variable. I can configure an id in the configuration input block or use the internal @id, but is the pipeline.id exposed to the plugin and/or log4j2?

This question is a bit similar to

> [@Logstash log4j configuration (log input id)](https://discuss.elastic.co/t/logstash-log4j-configuration-log-input-id/124616):
>
> Hello, I have pipelines with dozen of inputs/filters For some jdbc input, i meet errors : [2018-03-19T13:19:00,524][ERROR][logstash.inputs.jdbc] Unable to connect to database. Tried 1 times {:error\_message=\>"Java::JavaSql::SQLRecoverableException: IO Error: The Network Adapter could not establish the connection"} Every input{} in the logstash conf files have id input { jdbc {id =\> "my\_input\_id" Is there a way to configure log4j to have this id shown in logstash log Something like …

But since I wrote the plugin I can do @logger.info(@id). When I run logstash from the commandline and not as ubuntu service the @id does get printed as "main"

---

<div class="post-metadata">

**Author:** ![janmg](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@janmg](https://discuss.elastic.co/u/janmg)\
**Post date:** [February 27, 2019, 9:47am UTC](https://discuss.elastic.co/t/logstash-log4j-configuration-pipeline-id/169455/2 "2019-02-27T09:47:19Z")

</div>

So the pipeline\_id is not exposed to the plugin, but since it's part of the thread name, I can extract it from there. I can cut out the pipeline.id from between the [and], because the threadname is in the format

```auto
[pipeline.id]<plugin.name

```

For the configuration in log4j2.properties the threadname can be printed with %t, so it will look like this

```auto
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p]%t %-.10000m%n

```

you can strip some of the threadname by using the format modifiers, like %-6t if you use 4 character pipeline id's.

---

<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 27, 2019, 9:47am UTC](https://discuss.elastic.co/t/logstash-log4j-configuration-pipeline-id/169455/3 "2019-03-27T09:47:20Z")

</div>

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