diff --git a/src/main/java/org/opensearch/securityanalytics/util/SecurityAnalyticsException.java b/src/main/java/org/opensearch/securityanalytics/util/SecurityAnalyticsException.java index a5ed50f82..696862b25 100644 --- a/src/main/java/org/opensearch/securityanalytics/util/SecurityAnalyticsException.java +++ b/src/main/java/org/opensearch/securityanalytics/util/SecurityAnalyticsException.java @@ -39,7 +39,7 @@ public RestStatus status() { } public static OpenSearchException wrap(Exception ex) { - log.error(String.format(Locale.getDefault(), "Security Analytics error: %s", ex.getMessage())); + log.error("Security Analytics error:", ex); String friendlyMsg = "Unknown error"; RestStatus status = RestStatus.INTERNAL_SERVER_ERROR; @@ -52,7 +52,7 @@ public static OpenSearchException wrap(Exception ex) { } public static OpenSearchException wrap(OpenSearchException ex) { - log.error(String.format(Locale.getDefault(), "Security Analytics error: %s", ex.getMessage())); + log.error("Security Analytics error:", ex); String friendlyMsg = "Unknown error"; RestStatus status = ex.status(); @@ -71,10 +71,10 @@ public static OpenSearchException wrap(List ex) { XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); for (Exception e: ex) { builder.field("error", e.getMessage()); + log.error("Security Analytics error:", e); } builder.endObject(); String friendlyMsg = Strings.toString(builder); - log.error(String.format(Locale.getDefault(), "Security Analytics error: %s", friendlyMsg)); return new SecurityAnalyticsException(friendlyMsg, status, new Exception(String.format(Locale.getDefault(), "%s: %s", ex.getClass().getName(), friendlyMsg))); } catch (IOException e) {