application.ymlにRestTemplateのDEBUGログを出力する設定を以下のように追加。
logging:
level:
org.springframework.web.client.RestTemplate: DEBUG
確認
サービスにリクエストを実行して、内部で呼び出している外部API呼び出しのログがDEBUGログとして出力されている事を確認。
http://localhost:8080/tasks/12345
2021-01-05 07:27:15.978 INFO 13183 --- [nio-8080-exec-4] c.e.b.controller.TasksController : getTask is called with taskId(12345).
2021-01-05 07:27:15.979 DEBUG 13183 --- [nio-8080-exec-4] o.s.web.client.RestTemplate : HTTP GET http://localhost:50000/tasks/12345
2021-01-05 07:27:15.979 DEBUG 13183 --- [nio-8080-exec-4] o.s.web.client.RestTemplate : Accept=[application/json, application/*+json]
2021-01-05 07:27:16.586 DEBUG 13183 --- [nio-8080-exec-4] o.s.web.client.RestTemplate : Response 200 OK
2021-01-05 07:27:16.588 DEBUG 13183 --- [nio-8080-exec-4] o.s.web.client.RestTemplate : Reading to [com.example.bffsample.model.externalapi.Task]
2021-01-05 07:27:16.616 DEBUG 13183 --- [nio-8080-exec-4] o.s.web.client.RestTemplate : HTTP GET http://localhost:50001/users/1
2021-01-05 07:27:16.626 DEBUG 13183 --- [nio-8080-exec-4] o.s.web.client.RestTemplate : Accept=[application/json, application/*+json]
2021-01-05 07:27:16.804 DEBUG 13183 --- [nio-8080-exec-4] o.s.web.client.RestTemplate : Response 200 OK
2021-01-05 07:27:16.805 DEBUG 13183 --- [nio-8080-exec-4] o.s.web.client.RestTemplate : Reading to [com.example.bffsample.model.externalapi.User]
コメントを残す