2

The logs for my Spring Boot Java application are stored in CloudWatch. The problem is when exception occur the stacktrace is not properly coming, since it gets scattered across the CloudWatch. I tried all the logback.xml configs, but it is not working.

Is there any custom encoder java class to append all the stack trace of an exception into a single line so that it will be easy to track back

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

2 Answers2

2

When there is an exception use throwable to wrap in single line with a seperator

<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L %m %throwable{separator(|)} %n"/>
karthikmunna
  • 139
  • 1
  • 2
  • 14
0

logs can be sent as json to cloudwatch which has good support for filtering and matching json logs

try add logstash-logback-encoder to your dependencies and configure logback.xml to use LogstashEncoder

examples:

https://stackoverflow.com/a/68832699/1211547 https://www.innoq.com/en/blog/structured-logging/

indybee
  • 1,507
  • 13
  • 17