cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7389] Logging ClientErrorExceptions with FINE level, making it pisible to customize it
Date Thu, 31 Aug 2017 12:41:07 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 09aacad7d -> 61fb3fc3f


[CXF-7389] Logging ClientErrorExceptions with FINE level, making it pisible to customize it


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/61fb3fc3
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/61fb3fc3
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/61fb3fc3

Branch: refs/heads/master
Commit: 61fb3fc3fcfd2501afd16ff4f473e2ea653077c6
Parents: 09aacad
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Aug 31 13:39:30 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Aug 31 13:39:30 2017 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java  | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/61fb3fc3/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index ea42944..0ef6565 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -46,6 +46,7 @@ import java.util.TreeMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.HttpMethod;
 import javax.ws.rs.Produces;
@@ -526,7 +527,8 @@ public final class JAXRSUtils {
                                                    mediaTypeToString(requestType),
                                                    convertTypesToString(acceptContentTypes));
         if (!"OPTIONS".equalsIgnoreCase(httpMethod)) {
-            LOG.warning(errorMsg.toString());
+            Level logLevel = getExceptionLogLevel(message, ClientErrorException.class);
+            LOG.log(logLevel == null ? Level.FINE : logLevel, errorMsg.toString());
         }
         Response response =
             createResponse(getRootResources(message), message, errorMsg.toString(), status,
methodMatched == 0);
@@ -534,6 +536,25 @@ public final class JAXRSUtils {
 
     }
 
+    
+    
+    private static Level getExceptionLogLevel(Message message, Class<? extends WebApplicationException>
exClass) {
+        Level logLevel = null;
+        Object logLevelProp = message.get(exClass.getName() + ".log.level");
+        if (logLevelProp != null) {
+            if (logLevelProp instanceof Level) {
+                logLevel = (Level)logLevelProp;
+            } else {
+                try {
+                    logLevel = Level.parse(logLevelProp.toString());
+                } catch (Exception ex) {
+                    // ignore
+                }
+            }
+        }
+        return logLevel;
+    }
+
     private static List<MediaType> intersectSortMediaTypes(List<MediaType> acceptTypes,
                                                            List<MediaType> producesTypes,
                                                            final boolean checkDistance) {


Mime
View raw message