[SpringBoot] Verbose Logging

N'CHE·2022년 6월 24일
0
post-thumbnail

Create HttpServletRequest & HttpServletResponse Caching Wrapper

  • The original response body can only be read once, so caching is required.
  • It is a structure that wraps caching through an internal filter and sends it to the other beans.

Logging Format

  • Pretty human-readable JSON format
  • I plan to build a centralized logging system , so I decide to log in json format.
  • But, Pretty JSON was chosen for human debugging. 🥲
    Because there is no monitoring/notification system yet...
"Request" : {
  "Timestamp" : "2022-04-04 09:56:47.356",
  "Method" : "GET",
  "URI" : "",
  "Headers" : {
    "sec-fetch-mode" : "cors",
    "accept" : "*/*"
  },
  "Body" : null
}

 "Response" : {
  "Timestamp" : "2022-04-04 09:56:47.392",
  "Status" : 400,
  "Headers" : {
    "Vary" : "Origin"
  },
  "Body" : null
}
  • Among logback appneders, logback-jackson and logstash-logback-encoder applied to the project and then removed. Either because the output is in one-line Json format or because there is too much information I don't need. Format could be changed, but feature development is more important at the time,😭.
  • There was also the pros of being able to use MDC(Mapped Diagnostic Context) With logback-jackson and logstash-logback-encoder, but I didn't think it's necessary for the project that time.

0개의 댓글