From 37290ec2ebdf10d588e987f6b7b9fa46db325797 Mon Sep 17 00:00:00 2001 From: Chris Tremblay Date: Mon, 15 Jul 2024 15:44:23 -0400 Subject: [PATCH] logging header for troubleshooting --- .../petstoreapp/service/PetStoreServiceImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/petstore/petstoreapp/src/main/java/com/chtrembl/petstoreapp/service/PetStoreServiceImpl.java b/petstore/petstoreapp/src/main/java/com/chtrembl/petstoreapp/service/PetStoreServiceImpl.java index 70f9daca..00b3e755 100644 --- a/petstore/petstoreapp/src/main/java/com/chtrembl/petstoreapp/service/PetStoreServiceImpl.java +++ b/petstore/petstoreapp/src/main/java/com/chtrembl/petstoreapp/service/PetStoreServiceImpl.java @@ -74,6 +74,13 @@ public Collection getPets(String category) { try { Consumer consumer = it -> it.addAll(this.webRequest.getHeaders()); + // log all of the headers in the petServiceWebClient request + logger.info("Headers in the petServiceWebClient request " + this.containerEnvironment.getPetStorePetServiceURL()); + this.webRequest.getHeaders().forEach((k, v) -> { + logger.info("Key: " + k + " Value: " + v); + }); + logger.info("Key: " + "Ocp-Apim-Subscription-Key" + " Value: " + this.containerEnvironment.getPetStoreServicesSubscriptionKey()); + pets = this.petServiceWebClient.get().uri("petstorepetservice/v2/pet/findByStatus?status=available") .accept(MediaType.APPLICATION_JSON) .headers(consumer) @@ -107,6 +114,8 @@ public Collection getPets(String category) { pet.setCategory(new Category()); pet.setId((long) 0); pets.add(pet); + logger.error(wce.getMessage()); + } catch (IllegalArgumentException iae) { // little hack to visually show the error message within our Azure Pet Store // Reference Guide (Academic Tutorial) @@ -117,7 +126,9 @@ public Collection getPets(String category) { pet.setCategory(new Category()); pet.setId((long) 0); pets.add(pet); + logger.error(iae.getMessage()); } + return pets; }