From c4b5c32669423b9a792f33f9f8333d95528f2515 Mon Sep 17 00:00:00 2001 From: Xiao Chen Date: Thu, 8 Jun 2017 22:35:31 -0700 Subject: [PATCH] HADOOP-13854. KMS should log error details in KMSExceptionsProvider. --- .../java/org/apache/hadoop/crypto/key/kms/server/KMS.java | 2 +- .../hadoop/crypto/key/kms/server/KMSExceptionsProvider.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMS.java b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMS.java index 5873c7a501..27cc05d7ee 100644 --- a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMS.java +++ b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMS.java @@ -70,7 +70,7 @@ public enum KMSOp { private KeyProviderCryptoExtension provider; private KMSAudit kmsAudit; - private static final Logger LOG = LoggerFactory.getLogger(KMS.class); + static final Logger LOG = LoggerFactory.getLogger(KMS.class); public KMS() throws Exception { provider = KMSWebApp.getKeyProvider(); diff --git a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java index aa9d2995ab..3d977532df 100644 --- a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java +++ b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java @@ -43,6 +43,7 @@ public class KMSExceptionsProvider implements ExceptionMapper { private static Logger LOG = LoggerFactory.getLogger(KMSExceptionsProvider.class); + private final static Logger EXCEPTION_LOG = KMS.LOG; private static final String ENTER = System.getProperty("line.separator"); @@ -100,6 +101,9 @@ public Response toResponse(Exception exception) { KMSMDCFilter.getMethod(), KMSMDCFilter.getURL(), getOneLineMessage(exception)); } + EXCEPTION_LOG.warn("User {} request {} {} caused exception.", + KMSMDCFilter.getUgi(), KMSMDCFilter.getMethod(), + KMSMDCFilter.getURL(), exception); return createResponse(status, throwable); }