# Logstash multiline pattern

**URL:** <https://discuss.elastic.co/t/logstash-multiline-pattern/259997>\
**Category:** Logstash\
**Created:** [January 1, 2021, 2:20pm UTC](https://discuss.elastic.co/t/logstash-multiline-pattern/259997 "2021-01-01T14:20:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muhammad\_Faisal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muhammad_faisal/32/79213_2.png) [@Muhammad\_Faisal](https://discuss.elastic.co/u/Muhammad_Faisal)\
**Post date:** [January 1, 2021, 2:20pm UTC](https://discuss.elastic.co/t/logstash-multiline-pattern/259997/1 "2021-01-01T14:20:56Z")

</div>

hi guys,

i have a log file which consists of below pattern , i need to treat all lines of this log file as 1 aggregate event.file will close after 30 minutes and then new log will start..which pattern will work here... i am trying to use if line ends with new line feed , then merge next line with previous line ...but how to tell logstash that file has ended

`codec => multiline {`  
` pattern => ".*\r"`  
` negate => false`  
` what => "next"`

log format

DEBUG:root:some data  
DEBUG:root:some data  
DEBUG:root:exception  
DEBUG:root:error occured  
method finished

INFO:root:some data  
INFO:root:  
INFO:root:  
INFO:root:  
method complete

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 1, 2021, 4:06pm UTC](https://discuss.elastic.co/t/logstash-multiline-pattern/259997/2 "2021-01-01T16:06:43Z")

</div>

> [@Muhammad\_Faisal](#):
>
> i need to treat all lines of this log file as 1 aggregate event.file will close after 30 minutes

Use a pattern that will never match, and use a timeout

```
codec => {
    pattern => "^Spalanzani"
    negate => true
    what => next
    auto_flush_interval => 3700
}

```

---

<div class="post-metadata">

**Author:** ![Muhammad\_Faisal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muhammad_faisal/32/79213_2.png) [@Muhammad\_Faisal](https://discuss.elastic.co/u/Muhammad_Faisal)\
**Post date:** [January 2, 2021, 1:58pm UTC](https://discuss.elastic.co/t/logstash-multiline-pattern/259997/3 "2021-01-02T13:58:18Z")

</div>

its not getting last line into multiline... message aggregates all line except last ...

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 4, 2021, 6:19pm UTC](https://discuss.elastic.co/t/logstash-multiline-pattern/259997/4 "2021-01-04T18:19:49Z")

</div>

Is there a newline at the end of the last line?

---

<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:** [February 1, 2021, 6:20pm UTC](https://discuss.elastic.co/t/logstash-multiline-pattern/259997/5 "2021-02-01T18:20:09Z")

</div>

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