diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2019-09-12 17:02:46 +0300 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2019-09-12 17:02:46 +0300 |
commit | c729cb1356a3bacead0d9d63920c889966f64bdd (patch) | |
tree | cba32520d5e0df7c4e72412eb974aa4ca50b259a /vid-app-common/src/main/java/org/onap | |
parent | 2609cc76f0565466667fff8ae4d0707b94993877 (diff) |
logging of HttpResponse use raw body
print raw body for cases like errors
make sure the response can be read logging it
Issue-ID: VID-611
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Change-Id: If138531f515fb2927a13417040b68e81babebc4e
Diffstat (limited to 'vid-app-common/src/main/java/org/onap')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/utils/Logging.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java index 77b7ee869..0d8e58878 100644 --- a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java +++ b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java @@ -31,11 +31,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.google.common.collect.ImmutableList; import io.joshworks.restclient.http.HttpResponse; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Optional; import java.util.UUID; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; @@ -123,7 +125,9 @@ public class Logging { public <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final HttpResponse<T> response) { try { - logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.getBody()); + logger.debug("Received {} {} Status: {} . Body: {}", method.name(), + url, response.getStatus(), IOUtils.toString(response.getRawBody(), StandardCharsets.UTF_8)); + response.getRawBody().reset(); } catch (Exception e) { logger.debug("Received {} {} Status: {} . Failed to read response", method.name(), url, response.getStatus()); |