Skip to content

Spring Boot Logging HTTP with Trace Id Using Logback and AWS CloudWatch

Notifications You must be signed in to change notification settings

HyunAh-iia/spring-logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Logging

1. Logging HTTP Request/Response With Trace Id

  • Logging HTTP Request Method, URI, Query String, Content type and Payload
  • Logging HTTP Response
  • Trace Id for each HTTP Request
  • See commit 48e0d37a

2. Send Logs to AWS CloudWatch if Active Profile is dev, prod

  • If Active profile is dev or prod, Send Logs to CloudWatch
  • If not, Print Logs to Console
  • See commit 144d71f0

Test

  • Run SpringLoggingApplication
  • Call Sample API
curl "http://localhost:8080/sample?name=newiia"
  • Result : Console Log
2021-10-10 21:05:44.917 [http-nio-8080-exec-1] [traceId=bf5a5c08-02df-4c01-b7b2-3c8053547f7b] INFO  m.s.s.global.filters.LoggingFilter.logRequest - Request : GET uri=[/samplename=newiia] content-type=[null]
2021-10-10 21:05:44.949 [http-nio-8080-exec-1] [traceId=bf5a5c08-02df-4c01-b7b2-3c8053547f7b] INFO  m.s.s.global.filters.LoggingFilter.logPayload - Response Payload: hello! newiia

About

Spring Boot Logging HTTP with Trace Id Using Logback and AWS CloudWatch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages