# Multiline two new lines bewteen messages

**URL:** <https://discuss.elastic.co/t/multiline-two-new-lines-bewteen-messages/92654>\
**Category:** Logstash\
**Created:** [July 11, 2017, 1:19pm UTC](https://discuss.elastic.co/t/multiline-two-new-lines-bewteen-messages/92654 "2017-07-11T13:19:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Koller\_Nie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_koller_nie/32/18527_2.png) [@Christian\_Koller\_Nie](https://discuss.elastic.co/u/Christian_Koller_Nie)\
**Post date:** [July 11, 2017, 1:19pm UTC](https://discuss.elastic.co/t/multiline-two-new-lines-bewteen-messages/92654/1 "2017-07-11T13:19:13Z")

</div>

I have a logfile on the form:

```
aaa
bbb

aaa
bbb

aaa
bbb

```

and a .conf file:

```
input {
	file {
		path => "..."
		type => "j4"
		start_position => "beginning"
		codec => multiline {
			pattern => "^[^\r]"
			what => "previous"
			# line not starting with \r belongs to the previous line.
		}
	}	
}
filter {}
output {
	stdout {
		codec => rubydebug
	}
}

```

I want messages on the form "\raaa\r\n bbb\r"and this works with the following setup if there was just one line shift, but with two line shifts I have trouble figuring out how to get messages on that format. Can someone help?

---

<div class="post-metadata">

**Author:** ![CDR](https://avatars.discourse-cdn.com/v4/letter/c/d9b06d/32.png) [@CDR](https://discuss.elastic.co/u/CDR)\
**Post date:** [August 3, 2017, 2:05pm UTC](https://discuss.elastic.co/t/multiline-two-new-lines-bewteen-messages/92654/2 "2017-08-03T14:05:21Z")

</div>

In the filter part of your configuration file you can replace the two line shifts /n/n with a single line shift /n using the [gsub](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-gsub) command

---

<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:** [August 31, 2017, 2:05pm UTC](https://discuss.elastic.co/t/multiline-two-new-lines-bewteen-messages/92654/3 "2017-08-31T14:05:37Z")

</div>

Closed on August 31, 2017, 2:05pm UTC

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