# LogstashJ : Java bindings for Logstash

**URL:** <https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892>\
**Category:** Logstash\
**Created:** [February 16, 2016, 2:17pm UTC](https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892 "2016-02-16T14:17:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mogztter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mogztter/32/7820_2.png) [@Mogztter](https://discuss.elastic.co/u/Mogztter)\
**Post date:** [February 16, 2016, 2:17pm UTC](https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892/1 "2016-02-16T14:17:47Z")

</div>

Hello,

I've just started working on a Java binding for Logstash.  
My initial goal was to be able to write unit tests in Java but once we have a binding in place we could do so much more.

To give you some context, I'm working on a system where we handle more than 100 different types of events and we want to make sure that everything is working as expected. Currently we are running Rspec tests from a Maven build using Logstash distribution zip. This solution is working but it's not great.

With a Java binding, I could write a simple JUnit tests:

```java
@Test
public void should_lowercase_message() throws IOException {
  URL url = Resources.getResource(LogstashFilterTest.class, "filter_config.conf");
  String config = Resources.toString(url, Charsets.UTF_8);
  Pipeline pipeline = Logstash.Pipeline.create(config);
  Event event = pipeline.send("You don't need to YELL!");
  assertThat(event.getMessage()).isEqualTo("you don't need to yell!");
}

```

My main concern is that I have to declare explicitly every dependencies to create the Logstash distribution (default patterns, filters, codecs...).  
Also I don't know how I can provide a simple solution if a user want to unit test a custom filter or a use another version for a specific filter.

I'm aware that @colinsurprenant is already working on a project inside Logstash repository to create a Java API around event. As far as I know, the idea is to expose a pure Java API to plugins developers to support Java plugins.  
We have different goal but maybe we should work together to avoid doing the same thing twice ?

What do you think ?

---

<div class="post-metadata">

**Author:** ![colinsurprenant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colinsurprenant/32/14776_2.png) [@colinsurprenant](https://discuss.elastic.co/u/colinsurprenant)\
**Post date:** [March 2, 2016, 9:29pm UTC](https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892/2 "2016-03-02T21:29:58Z")

</div>

Hi @Mogztter - sorry for the delay, I am currently on vacation and will return on March 7th. I will followup with you on that week.

Thanks,  
Colin

---

<div class="post-metadata">

**Author:** ![Mogztter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mogztter/32/7820_2.png) [@Mogztter](https://discuss.elastic.co/u/Mogztter)\
**Post date:** [March 3, 2016, 7:07pm UTC](https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892/3 "2016-03-03T19:07:00Z")

</div>

No worries, enjoy your vacation 😄

---

<div class="post-metadata">

**Author:** ![udaykirankona](https://avatars.discourse-cdn.com/v4/letter/u/ac91a4/32.png) [@udaykirankona](https://discuss.elastic.co/u/udaykirankona)\
**Post date:** [December 22, 2016, 1:16pm UTC](https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892/4 "2016-12-22T13:16:49Z")

</div>

Hi Mogztter,

Did you get any solution for this?

I am trying the same..

Thanks,  
Uday.K

---

<div class="post-metadata">

**Author:** ![Mogztter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mogztter/32/7820_2.png) [@Mogztter](https://discuss.elastic.co/u/Mogztter)\
**Post date:** [December 22, 2016, 6:17pm UTC](https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892/5 "2016-12-22T18:17:16Z")

</div>

Not really but Logstash (core) is making good progress on the Java API: [https://github.com/elastic/logstash/tree/master/logstash-core-event-java](https://github.com/elastic/logstash/tree/master/logstash-core-event-java)

I think the best approach here is to use the new Java API provided by Logstash to create a Java testing library for Logstash.

---

<div class="post-metadata">

**Author:** ![udaykirankona](https://avatars.discourse-cdn.com/v4/letter/u/ac91a4/32.png) [@udaykirankona](https://discuss.elastic.co/u/udaykirankona)\
**Post date:** [January 19, 2017, 7:47am UTC](https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892/6 "2017-01-19T07:47:22Z")

</div>

Thanks, I will check that.

---

<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:** [July 6, 2017, 4:29am UTC](https://discuss.elastic.co/t/logstashj-java-bindings-for-logstash/41892/7 "2017-07-06T04:29:17Z")

</div>


