# Why do messages and Error stack trace do not recognize new line charecters

**URL:** <https://discuss.elastic.co/t/why-do-messages-and-error-stack-trace-do-not-recognize-new-line-charecters/117346>\
**Category:** Logstash\
**Created:** [January 28, 2018, 5:39am UTC](https://discuss.elastic.co/t/why-do-messages-and-error-stack-trace-do-not-recognize-new-line-charecters/117346 "2018-01-28T05:39:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SawyerFord](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SawyerFord](https://discuss.elastic.co/u/SawyerFord)\
**Post date:** [January 28, 2018, 5:39am UTC](https://discuss.elastic.co/t/why-do-messages-and-error-stack-trace-do-not-recognize-new-line-charecters/117346/1 "2018-01-28T05:39:58Z")

</div>

I would like to know why new lines (\n) are available in the strack trace and why are not getting displayed in a new line. What settings I have to make such that the error stack trace appear with new line as traditional loggers and message also has has all the backslash special charecters ''

```
{
"@timestamp": "2018-01-27T14:52:36.708+04:00",
"@version": 1,
"message": "Invalid Request Exception: "responsePayload\":\"{\\\"status\\\":\\\"FAIL\\\",\\\"statusCode\\\":1190,\\\"",
"logger_name": "com.json.logging.demo.web.controller.ErrorHandler",
"thread_name": "http-nio-3009-exec-1",
"level": "ERROR",
"level_value": 40000,
"stack_trace": "com.json.logging.demo.exception.PullEmployeeDataException: null\n\tat    
 com.json.logging.demo.web.controller.admin.EmployeeCodeController$ 
$FastClassBySpringCGLIB$$15b35cb5.invoke(<generated>)\n\tat 
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)\n\tat 
org.springframework.aop.framework.CglibAopProxy$ glibAopProxy.java:721)\n\"

 }

```

I expect the output as below. I expect that the output should omit backslash charecters () and read new lines and spaces (\n\t) and print as below

```
     {
"@timestamp": "2018-01-27T14:52:36.708+04:00",
"@version": 1,
"message": "Invalid Request Exception: "responsePayload\":\"{ "status ": "FAIL ", "statusCode ":1190,"",
"logger_name": "com.json.logging.demo.web.controller.ErrorHandler",
"thread_name": "http-nio-3009-exec-1",
"level": "ERROR",
"level_value": 40000,
"stack_trace": "com.json.logging.demo.exception.PullEmployeeDataException: null
  at com.json.logging.demo.web.controller.admin.EmployeeCodeController
                $FastClassBySpringCGLIB$$15b35cb5.invoke(<generated>) 
  at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  at org.springframework.aop.framework.CglibAopProxy$ glibAopProxy.java:721)"

 }
```

---

<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:** [January 30, 2018, 6:49am UTC](https://discuss.elastic.co/t/why-do-messages-and-error-stack-trace-do-not-recognize-new-line-charecters/117346/2 "2018-01-30T06:49:27Z")

</div>

Instead of describing what you expect, show it! What would you like the JSON object above to look like?

---

<div class="post-metadata">

**Author:** ![SawyerFord](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SawyerFord](https://discuss.elastic.co/u/SawyerFord)\
**Post date:** [January 30, 2018, 7:02am UTC](https://discuss.elastic.co/t/why-do-messages-and-error-stack-trace-do-not-recognize-new-line-charecters/117346/3 "2018-01-30T07:02:42Z")

</div>

added the expected output in the description

---

<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:** [January 30, 2018, 7:10am UTC](https://discuss.elastic.co/t/why-do-messages-and-error-stack-trace-do-not-recognize-new-line-charecters/117346/4 "2018-01-30T07:10:52Z")

</div>

What you want to have isn't valid JSON.

---

<div class="post-metadata">

**Author:** ![SawyerFord](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SawyerFord](https://discuss.elastic.co/u/SawyerFord)\
**Post date:** [January 30, 2018, 7:14am UTC](https://discuss.elastic.co/t/why-do-messages-and-error-stack-trace-do-not-recognize-new-line-charecters/117346/5 "2018-01-30T07:14:30Z")

</div>

I have added the missing ". what I expect is that the JSON should not have the \n\t charecters inside the stacktrace or inside the message attritubute. I have applied the below config in logstash.conf but it didnt work

```
 input {
 stdin {
     codec => multiline {
     pattern => "^\s"
     what => "previous"
  }
   }
 }
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:** [February 27, 2018, 7:27am UTC](https://discuss.elastic.co/t/why-do-messages-and-error-stack-trace-do-not-recognize-new-line-charecters/117346/6 "2018-02-27T07:27:16Z")

</div>

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