# Logstash parse multiline logging

**URL:** <https://discuss.elastic.co/t/logstash-parse-multiline-logging/307995>\
**Category:** Logstash\
**Created:** [June 23, 2022, 11:23am UTC](https://discuss.elastic.co/t/logstash-parse-multiline-logging/307995 "2022-06-23T11:23:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ceesz](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@Ceesz](https://discuss.elastic.co/u/Ceesz)\
**Post date:** [June 23, 2022, 11:23am UTC](https://discuss.elastic.co/t/logstash-parse-multiline-logging/307995/1 "2022-06-23T11:23:22Z")

</div>

Hi all,

I am trying to parse the following log file with multi-log lines:

```auto
Benutzerkennung: test1
Uhrzeit: 20:53:54 14.05.2022
Version: Microsoft Dynamics AX 6.2 (Erstellungsnummer 3000.5768)
Datenbank: Microsoft SQL Server
Arbeitsgang: 'BLABLA' (ID #109457): FIELD(NEW)
Dauer in Teilstrichen: 109.

Benutzerkennung: test1
Uhrzeit: 23:19:00 02.06.2022
Version: Microsoft Dynamics AX 6.2 (Erstellungsnummer 3000.5768)
Datenbank: Microsoft SQL Server
Arbeitsgang: 'BLABLA' (ID #115286): TABLE(NEW)+INDEX(CREATE)

```

With the following config:

```auto
input {
    tcp {
        port => 1337
        codec => multiline {
            pattern => "Arbeitsgang(.*)(\n)"
            what => "next"
            negate => true
        }
    }

}

output {
    stdout { codec => rubydebug }
}

```

However, I am not getting the desired output. Note that the line "Dauer in Teilstrichen: X." can be omitted. The desired output is as following:

- Log line 1:

> Benutzerkennung: test1 Uhrzeit: 20:53:54 14.05.2022 Version: Microsoft Dynamics AX 6.2 (Erstellungsnummer 3000.5768) Datenbank: Microsoft SQL Server Arbeitsgang: 'BLABLA' (ID #109457): FIELD(NEW)

- Log line 2:

> Benutzerkennung: test1 Uhrzeit: 23:19:00 02.06.2022 Version: Microsoft Dynamics AX 6.2 (Erstellungsnummer 3000.5768) Datenbank: Microsoft SQL Server Arbeitsgang: 'BLABLA' (ID #115286): TABLE(NEW)+INDEX(CREATE)

I am not getting the wanted result, can someone help me out?

---

<div class="post-metadata">

**Author:** ![Ceesz](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@Ceesz](https://discuss.elastic.co/u/Ceesz)\
**Post date:** [June 23, 2022, 12:36pm UTC](https://discuss.elastic.co/t/logstash-parse-multiline-logging/307995/2 "2022-06-23T12:36:43Z")

</div>

Edit,

I got it working with the config below. _However,_ the flush doesnt seem to work. The last item is _only_ processed when I manually kill the TCP connection:

```auto
input {
    tcp {
        port => 1337
        codec => multiline {
            pattern => "Benutzerkennung"
            negate => true
            what => "previous"
            auto_flush_interval => 5
        }
    }

}

output {
    stdout { codec => rubydebug }
}

```

---

<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 21, 2022, 12:37pm UTC](https://discuss.elastic.co/t/logstash-parse-multiline-logging/307995/3 "2022-07-21T12:37:20Z")

</div>

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