# Logstash json parsing error to read logback json file

**URL:** <https://discuss.elastic.co/t/logstash-json-parsing-error-to-read-logback-json-file/88644>\
**Category:** Logstash\
**Created:** [June 8, 2017, 1:38am UTC](https://discuss.elastic.co/t/logstash-json-parsing-error-to-read-logback-json-file/88644 "2017-06-08T01:38:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juneyoung\_Oh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juneyoung_oh/32/18729_2.png) [@Juneyoung\_Oh](https://discuss.elastic.co/u/Juneyoung_Oh)\
**Post date:** [June 8, 2017, 1:38am UTC](https://discuss.elastic.co/t/logstash-json-parsing-error-to-read-logback-json-file/88644/1 "2017-06-08T01:38:43Z")

</div>

Hi. I am trying to read and store tomcat logs into elasticsearch via logstash.  
The json file which made by logback looks like below.

```
{
  "@timestamp" : "2017-06-08T09:33:48.579+09:00",
  "@version" : 1,
  "message" : "FrameworkServlet 'dispatcherServlet': initialization completed in 1851 ms",
  "logger_name" : "org.springframework.web.servlet.DispatcherServlet",
  "thread_name" : "http-nio-8090-exec-1",
  "level" : "INFO",
  "level_value" : 20000,
  "HOSTNAME" : "Juneui-MacBook-Pro.local"
}
{
  "@timestamp" : "2017-06-08T09:33:48.631+09:00",
  "@version" : 1,
  "message" : "index() called, hits was 'null', session id '94DCBEF7DF26440F321F083D574EC747'",
  "logger_name" : "org.owls.session.SessionTestController",
  "thread_name" : "http-nio-8090-exec-1",
  "level" : "INFO",
  "level_value" : 20000,
  "HOSTNAME" : "Juneui-MacBook-Pro.local"
}

```

and my logstash config like

```
input {
  file {
    codec => json
    type => json
    path => '/etc/logstash/logs/log*.json'
  }
}

filter {
  json {
    source => 'message'
  }
}

output {
  elasticsearch {
    hosts => ['localhost:9200']
    index => 'elk-%{+YYYY.MM.dd}'
    document_type => 'log'
  }
  stdout { codec => rubydebug }
}

```

I put `type` and `codec`, when I watch the logstash log, it prints `jsonparse failure`. I also tried input `codec => json_lines`, but did not work well.

Here is logstash error log for your information,

```
{
          "path" => "/etc/logstash/logs/log.json",
    "@timestamp" => 2017-06-08T01:36:41.467Z,
      "@version" => "1",
          "host" => "f49930138437",
       "message" => "}",
          "type" => "json",
          "tags" => [
        [0] "_jsonparsefailure"
    ]
}

```

How can I fix this?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 9, 2017, 8:54am UTC](https://discuss.elastic.co/t/logstash-json-parsing-error-to-read-logback-json-file/88644/2 "2017-06-09T08:54:49Z")

</div>

You'll have to use a multiline codec to join the lines of a JSON message into a single event. The multiline logic could be "unless the line is a lone opening brace, join the current line with the previous 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:** [July 7, 2017, 8:55am UTC](https://discuss.elastic.co/t/logstash-json-parsing-error-to-read-logback-json-file/88644/3 "2017-07-07T08:55:15Z")

</div>

Closed on July 7, 2017, 8:55am UTC

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